Skip to main content
17 votes
Accepted

Visual Block Mode edit with sequential number

Depending on your usecase the following might be useful: Create the entries all with the number "1": - "1" - "1" - "1" - "1" Then go to the second "1" and press V to start line-wise visual. Then ...
Ralf's user avatar
  • 9,417
14 votes

How can I show relative line numbers?

If you want to use a hotkey for toggling relative line number, here is a snippet in my vimrc: " Toggle relative line number nmap <C-L><C-L> :set invrelativenumber<CR> In this case, ...
Sean Lee's user avatar
  • 141
8 votes
Accepted

Vim never shows line number for Python files even though I have `.vimrc`

Why it didn't work From :help FileType, *FileType* FileType When the 'filetype' option has been set. The pattern is matched against the ...
D. Ben Knoble's user avatar
  • 27.7k
7 votes

Why this function to change relative number in lines is not working?

Why won't you use Vim's builtin feature to toggle that? Just use: set relativenumber! - this will cycle between on and off.
grodzik's user avatar
  • 4,738
7 votes
Accepted

Nvim can not detect focus change inside tmux sessions

I opened an issue on Neovim repo and get the right answer. We need to turn on the focus-events for tmux. Edit the tmux config file ~/.tmux.conf and add the following setting: set -g focus-events on ...
jdhao's user avatar
  • 1,143
6 votes
Accepted

Get rid of extra gutter spacing

Vim automatically sets the gutter spacing, but it has some constraints. Notably, numberwidth determines the minimum number of columns reserved for the gutter. The default is 4, 3 for the numbers and ...
Eggrenade's user avatar
  • 101
6 votes
Accepted

What are the benefits and use cases of relativenumber?

TL;DR relative numbers are just another tool in the toolbox they can be effective in terms of locality when a text-object doesn't cut it (and for the lazy-minded among us) they pair nicely with ...
D. Ben Knoble's user avatar
  • 27.7k
5 votes
Accepted

How to toggle relative number for all opened windows?

Yes, using :h :windo: nnoremap <C-a> :windo set relativenumber!<CR>
Jake Grossman's user avatar
5 votes
Accepted

Why are relative line numbers useful in Vim?

One reason for relative line number is that some Vim command use relative line number or relative range. A trivial example is 4j that moves 4 line down relative to the current line number. But there ...
Vivian De Smedt's user avatar
4 votes

How can I generate a list of sequential numbers, one per line?

I know this question is really old, but there's another way you can do it also. Try this: 99o<esc>:%s/^/\=line('.')<cr> 99o<esc> will just open up 100 blank lines. Then, we run a ...
DJMcMayhem's user avatar
  • 17.9k
4 votes

Relative Numbers sidepanel with wrapped lines

You state that your current workflow is "inaccurate" and "less usable". You can solve the former (but arguably not the latter) by replacing your current j mapping with: nnoremap <expr> j v:...
Rich's user avatar
  • 32.6k
4 votes
Accepted

Vim ignore terminal color schemes when setting colors

By using color names like cyan or black or numbers below 16 you are actively telling Vim to use your terminal color scheme. If you don't want Vim to use your terminal emulator color scheme you will ...
romainl's user avatar
  • 42.3k
4 votes
Accepted

Send file and line number to tmux

Here's an example of inserting line number in a shell command: :exe "!echo " . line(".") So your mapping would be something like this: nnoremap <silent> <leader>ef :exe "!tmux send -t 0....
B Layer's user avatar
  • 20.1k
4 votes
Accepted

Why this function to change relative number in lines is not working?

The intention of the function as described in the blog post is not to toggle relativenumber but to switch between the number and relativenumber settings. In Vim 7.3, the number and relativenumber ...
Rich's user avatar
  • 32.6k
4 votes
Accepted

How could I turn off the terminal line number while keep the editor line number in vimrc

Thanks the helpful comment provided by Christian Brabandt. The answer is to add a line in the .vimrc: autocmd TerminalOpen * set nonu
coin cheung's user avatar
4 votes
Accepted

Line number order is broken

In SpaceVim, we use g:spacevim_relativenumber to config relativenumber. if by default it is 1, if you want to disable this feature. just add let g:spacevim_relativenumber = 0 to your custom config. ...
Eric Wong's user avatar
  • 530
4 votes
Accepted

How to copy lines with line numbers?

You have several alternatives. Use the TOhtml command to let Vim generate an HTML file, which includes the line numbers, and then copy and paste from that file. Replace each line by its line number ...
4 votes
Accepted

How to open multiple files with cursor for all files being at the last line?

You can use vim *.log +'argdo norm! G' See :h [+cmd] :h :argdo :h :norm The + [cmd] allows you to run an ex command when you start vim and the command argdo norm! G will run norm! G on all the ...
statox's user avatar
  • 50.5k
4 votes
Accepted

line numbers in vim -H reversed

As it turns out, this was an obscure bug, that was caused by patch 8.1.1073. I have just submitted a patch to fix this issue and it has just been included as of Patch v8.2.3012
Christian Brabandt's user avatar
4 votes

How supply range to normal mode key-binding?

Assuming the cursor is on line #80 and <leader> defaults to backslash, type directly 2\t. The point is that typing N: in Normal mode, where N is arbitrary number, is converted by Vim to :.,.+N-1....
Matt's user avatar
  • 21.6k
4 votes
Accepted

How can I add a specific range of numbers into to each line at a particular location?

The example in :help v_g_Ctrl-A illustrates how to use Visual mode and g Ctrl-A to have a sequence of running numbers on each line. We modify that example slightly and use a general starting number: ...
husB's user avatar
  • 2,143
4 votes

How can I add a specific range of numbers into to each line at a particular location?

Short answer Use g<c-a> in visual-block mode to create an incrementing list from selected numbers. This can be done in a few steps in normal mode. Place your cursor where you want your number ...
Biggybi's user avatar
  • 2,770
3 votes

Sharing gutter space between line numbers and YCM markers

You could try and use DynamicSigns. The documentation includes an example to show relative line numbers every 5 lines. Maybe you can adopt the example and use this plugin combined with YCM.
mike's user avatar
  • 957
3 votes

Line number order is broken

Custom config didn't work for me. So I did this: $ find ~/.SpaceVim/ -type f | xargs grep spacevim_relativenumber And found the line in .SpaceVim//autoload/SpaceVim.vim: let g:...
Roman Pushkin's user avatar
3 votes

In VIM, Change the number that relative lines numbers start from

You seem to be confusing ranges with counts. d, y c, etc, take counts, not ranges, so will not work the way you expect. Commands that take a range, such as :substitute, will work with relative ...
Herb's user avatar
  • 1,213
3 votes

How to show the sign column to the right side of the line number column?

As stated by Christian in his comment, this is unfortunately impossible. However, from patch 8.1.1564, there's an option that could solve this problem. We can merge the signcolumn and the line numbers....
Biggybi's user avatar
  • 2,770
3 votes
Accepted

Automatically set the 'number' option in Vim when entering Ex mode, set 'nonumber' in visual mode

For Vim. 1) Create a mapping to enter Ex mode and turn on numbers: nnoremap Q Qset number<CR> 2) Create a function to turn numbering off: fun! NoNumber() set nonumber return '' ...
Antony's user avatar
  • 2,610
3 votes

Nvim can not detect focus change inside tmux sessions

My understanding of this issue is that xterm-compatible terminals (at least...there may be others) emit a certain control sequence when focus is gained/lost from a terminal window. Rather than Vim, ...
B Layer's user avatar
  • 20.1k
3 votes

Highlight specific line numbers in the gutter

Works only in neovim highlight CustomError ctermfg=red guifg=red sign define error numhl=CustomError sign place 2 name=error line=7 Have a look, at :h sign
Hritik's user avatar
  • 131
3 votes

Show absolute and relative line numbers (not hybrid)

Take a look at this answer. You can use RltvNmbr to display the relative line numbers while Vim displays the absolute ones.
Steven Fontanella's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible