GithubHelp home page GithubHelp logo

myusuf3 / numbers.vim Goto Github PK

View Code? Open in Web Editor NEW
745.0 16.0 47.0 99 KB

numbers.vim is a vim plugin for better line numbers

Home Page: http://myusuf3.github.com/numbers.vim/

License: MIT License

Vim Script 100.00%

numbers.vim's Introduction

numbers.vim

numbers.vim is a plugin for intelligently toggling line numbers.

This plugin alternates between relative numbering (relativenumber) and absolute numbering (number) for the active window depending on the mode you are in. In a GUI, it also functions based on whether or not the app has focus.

Commands are included for toggling the line numbering method and for enabling and disabling the plugin.

Requirements

  • Vim 7.3+

Installation

Using pathogen or vundle for installation is recommended.

For pathogen users, clone the repo:

git clone https://github.com/myusuf3/numbers.vim.git ~/.vim/bundle/numbers

For vundle users, add the following to your .vimrc and then run a :BundleInstall:

Bundle "myusuf3/numbers.vim"

Numbers Don't Belong

If you see numbers where they don't belong like in the help menus or other vim plugins be sure to add your plugins to the excludes list in your vimrc like so

let g:numbers_exclude = ['tagbar', 'gundo', 'minibufexpl', 'nerdtree']

The plugin by default contains the following:

let g:numbers_exclude = ['unite', 'tagbar', 'startify', 'gundo', 'vimshell', 'w3m']$

So be sure to include the superset in your vimrc or gvimrc

Usage

Once installed, no action is required on your part. But for convenience, you may want to add mappings in your .vimrc for some of the commands, e.g.,

nnoremap <F3> :NumbersToggle<CR>
nnoremap <F4> :NumbersOnOff<CR>

Vim 7.4

If you are lucky enough to be a Vim 7.4 user, you may experience unexpected behaviour if set number is not present in your ~/.vimrc.

numbers.vim's People

Contributors

bengl avatar benspaulding avatar blindfs avatar bmcorser avatar evanrelf avatar jakobr avatar korken89 avatar mrpdaemon avatar myusuf3 avatar rhysd avatar ryanmcg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

numbers.vim's Issues

NumbersToggle on Vim 7.4 hides numbers rather than toggles

On Vim 7.4, invoking NumbersToggle hides the line numbers rather than toggling between relativenumber and number. I believe the cause is that NumbersToggle calls NumbersRelativeOff, which simply calls set relativenumber if Vim version is 7.4 and does not call set number. In other words, the else should not be there in NumbersRelativeOff.

NERDTree compatibility

Hey,

Love numbers.vim! Awesome job! Thank you.

I use NERDTree with NERDTreeShowLineNumbers=1 in my rc. When starting vim with NERDTreee I have to NumbersToggle before I can have the same behaviour as starting vim on a file, eg. with 'vim .'.

Don't know if that is a NERDTree problem or a numbers problem. Let me know if you have any questions.

Cheers

  • Tilman

Slowness still persistent even after regexpengine workaround

Hi, I've been experiencing some pretty bad lag with vim when editing files at around 400-500~ lines or greater length. I've found the previous issue (#53), and tried the workaround but it doesn't help much. However, toggling relative line numbers off completely solves the issue.

I'm also running on a pretty powerful machine here. 3.5 GHz quad core, 16 GB ram, running Ubuntu. When just scrolling down in the file, I see an entire 100% usage of a core on the CPU.

vim 7.4, Ubuntu 14.04 Trusty Tahr

My absoulte number just gone away after update.

Weird, this changes c30ef58 made my absolute number gone away, I have to revert this change to get the original behaviour.

It seems the norelativenumber equal to nonumber in my case. My vim patch is 7.3.923 compiled by myself under ubuntu 13.04.

:NumbersToggle then insert mode changes normal mode numbering

If I am in relative numbers in normal mode, and I invoke :NumbersToggle, I get absolute numbers. If I then go to insert mode and escape, I am back to relative numbers in normal mode. I would have expected to stay in absolute numbers in normal mode. As it stands, I have to enter :NumbersToggle (or a shortcut that runs this) every time I escape from insert mode, it appears.

Toggle in command mode?

Is there a way to switch to absolute numbers when using command mode, then switch back after returning to normal? I've found myself having to count lines visually to do certain things. For example, I like to do something like :14y to yank line 14 without moving the cursor. I keep yanking the wrong line because I forget the lines are relative lol! Any suggestions?

g:numbers_exclude not working for easybuffer in Vim 7.4

Including easybuffer in g:numbers_exclude did not work on vim 7.4 (I believe it did work on 7.3). It turns out that in my case easybuffer is setting it's filetype to late and at the time BufNewFile is called it's still empty.

My solution for that is to use Filetype event to call ResetNumbers but I don't know if this should be done instead of BufNewFile event or in addition to. What do you think?

:NumbersOnOff does not seem to work at all.

@myusuf3 I thought about mentioning this on twitter but 140 characters is hard to debug :-P

I do not get anything when I run :NumbersOnOff. Nothing happens at all.

vim 7.3+, recently :BundleInstall'ed numbers, everything else works fine but I can't toggle the numbers with :NumbersOnOff

Does not play nice in VSCode|VSCodium through the neovim extension

I figured this out with the help of the maintainers of that extension, here:
vscode-neovim/vscode-neovim#742

background info:

  • VSCodium is the non-Microsoft version of VSCode (just branding changed, and not compiled by MS)
  • There is an extension (plugin) for VSCode, that allows to hijack an external, native neovim binary, to be able to navigate/edit text the Vim way (with insert- and normal-mode and what not)
  • If that neovim is configured to use myusuf3/numbers.vim, switching to insert-mode with i makes the cursor jump 4 chars to the right
  • This effect disappears after some time working in the file, and re-appears every time one switches to an other tab.

I assume, you do not care much, and it is not really an issue with your plugin, I assume, but maybe you want to document it in the README?
Either way... thanks for the plugin, it is great when using Vim natively! :-)

Toggling Numbers On/Off, Relative vs. Absolute

Unfortunately, the plug-in didn't work for me with regard to hidding/showing numbers.

Instead, I wrote these functions, which work for me.

" F3 – Toggle relative numbers
" F4 – Toggle numbers

" Source: vim.fandom.com/wiki/Managing_set_options#Boolean_options
  nnoremap <F3> :call ToggleRelativeNumber()<CR>
  function! ToggleRelativeNumber()
    if &number
      if &relativenumber
        set norelativenumber
      else
        set relativenumber
      endif
    endif
  endfunction

" Source: stackoverflow.com/a/14976446
  nnoremap <F4> :call ToggleNumbers()<CR>
  function! ToggleNumbers()
    if &number
      set norelativenumber nu!
    else
      set number
    endif
  endfunction

Number Toggle on ^o

When in insert mode you can switch to normal mode for one command with C-o. Currently numbers.vim toggles to relative line numbers when hitting C-o from insert mode (since you're technically then in normal mode), and then after the one command is run, goes back to absolute line numbers.

Personally I think it would be better if line numbers stayed absolute through that whole process. If nothing else it would be nice to have the option.

Config default mode absolute

Remapped toggling and would like to turn relative numbers only occasionally.

How to make it default to absolute numbers in normal mode?

Extreme slowness on large files with Vim 7.4 on Ubuntu

Hi,

I am using this plugin with vim 7.4.000 (Ubuntu saucy) and I get an extremly high cpu usage while scrolling a file with a lot of nested lines.

No problems at all under Ubuntu precise that use vim 7.3.429.

Any idea?

exclude buffergator but don't work

I use this in my .vimrc

let g:numbers_exclude = ['tagbar', 'gundo', 'buffergator', 'nerdtree'] 

the buffergator aways show the line number.
pls fix this. thank you so much.

Warning msg when updating via BundleInstall!

When using the BundleInstall! command from Vundle to update all plugins, numbers.com spits out the below warning.
Requires Vim 7.3+ Failed loading numbers.vim
However it works fine after a restart of vim

I believe it's because of the the following check
if exists("g:numbers") || v:version < 703 || &cp,

ie it barfs if the script is already loaded.

Should the script be safe to reload? Most other plugins are.

Something conflicts

I really love the plugin, but it acts really strange for me.

conflict

I really don't know what can be the reason for it, but I can't use it for now. Any ideas how to fix it?

P.S. Here's my current .vimrc.

Show regular line numbers with relative in 2 columns

Is it possible to show both, actual line numbers and relative line numbers?

Either in a 2 column design or ones on one side of the screen and the others on the other side of the screen?

If someone can point me to some documentation, I'm happy to put together a pull request. I'm just not sure where to start looking for this.

bad behavior after upgrading vim

After upgrading vim to 7.4, the :NumbersOnOff stopped working and every time I enter the Insert mode the numbers disappear.

Any idea?

Line numbers displayed in NERDTree buffer regardless of settings

When using the most recent version of numbers.vim and NERDTree, line numbers are shown within the NERDTree browse buffer. This happens regardless of the NERDTree settings, or the buffer specific settings. If you change the settings on the NERDTree buffer via :set nonumber then <C-w><C-W> numbers will be redisplayed.

It does not seem to respect the NERDTree variable NERDTreeShowLineNumbers either.

Before the last release of numbers.vim this behavior did not occur.

Removing the numbers.vim plugin reverts NERDTree to it's original behavior.

Leave numbers visible in Insert Mode?

Hey,

this may be a n00b question but I want the line numbers to stay visible even when I go into insert mode. Currently they are disappearing for me.

How do I do this?

Thanks,
Pat

Cannot hide number in nvim terminal

Steps to reproduce:

  1. Install numbers.vim
  2. Open a terminal via :term in neovim
  3. :set nonumber
  4. :set norelativenumber. Now the number disappears
  5. Switch to other buffers. Now the number appears again.

I checked the source of numbers.vim, it could disable the numbering by setting g:numbers_exclude to blacklist certain filetypes. However, since terminal window has empty 'filetype', we cannot use this option to blacklist terminal window. Instead, we should add another option to blacklist certain 'buftype'.

Error detected while processing function SetNumbers..ResetNu

Since commit:
6b121f3
Use new NumbersRelativeOff 7.3.1115 compatibility

I get the following error message everytime I toggle between insert and normal mode:

Error detected while processing function SetNumbers..ResetNumbers..NumbersRelativeOff:
line 3:
E15: Invalid expression:

Any suggestions?

Can't switch to non-relative line numbers

Been reading the docs regarding switching between modes. And it could be because the commands are extremely counter intuitive, but I can't seem to move out of relative number mode regardless of trying different combinations of enable, disable, onoff, toggle, etc. Any additional info you may need I can provide if it's a bug or if the docs/commands are unclear

NERDTree aways show the line numbers

I have NERDTreeShowLineNumbers=0 in my vimrc, but when I use to change windows in vim. the line numbers are still displayed in NERDTree. I don't want them.

7.2 support

What is the reason that 7.3 is required? How much effort would it take to fork for 7.2? 7.3 isn't really in wide enough distribution yet, especially on enterprise systems.

Fix the inclusion guard

In order to be able to enable/disable this plugin from the .vimrc file, you need to use the g:numbers as an inclusion guard. Eg:

if exists("g:numbers")
    finish
endif
if v:version < 703 || &cp
    "....
endif

Vundle compatibility?

I use https://github.com/gmarik/vundle to manage my vim setup, but your plugin isn't installing clean on my vundle + vim73 setup.

Any chance you could add compatibility for this? I took a quick look to see if I could but frankly I am not a vimscript expert and wasn't sure why it causing errors.

[120628 10:55:01] > Cloning into /home/vagrant/.vim/bundle/numbers...^@fatal: https://github.com/myusuf3/numbers/info/refs not found: did you run git update-server-info on the server?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.