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 ...
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, ...
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 ...
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.
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
...
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 ...
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 ...
5
votes
Accepted
How to toggle relative number for all opened windows?
Yes, using :h :windo:
nnoremap <C-a> :windo set relativenumber!<CR>
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 ...
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 ...
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:...
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 ...
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....
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 ...
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
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. ...
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 ...
Community wiki
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 ...
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
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....
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:
...
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 ...
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.
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:...
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 ...
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....
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 ''
...
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, ...
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
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.
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
line-numbers × 90vimrc × 13
vimscript × 6
neovim × 4
key-bindings × 3
autocmd × 3
substitute × 3
vim-windows × 3
visual-mode × 3
highlight × 3
ex-mode × 3
options × 3
wrapping × 3
multiple-lines × 3
range × 3
buffers × 2
cut-copy-paste × 2
colorscheme × 2
normal-mode × 2
insert-mode × 2
cursor-motions × 2
replace × 2
external-command × 2
folding × 2
netrw × 2