Skip to main content

Questions tagged [line-numbers]

Vim can output the number of each line on the left side of the screen. Questions about customizing this behavior.

Filter by
Sorted by
Tagged with
0 votes
1 answer
63 views

Having a modified relativenumber

In my experience with vim I found relative numbers pretty useful. But I would like to know if is there an argument I could give to the my neovim configuration file so I could configure it in such way ...
KnownAsDon's user avatar
3 votes
2 answers
2k views

How can I have more space between line number and code?

Bascially, I want to increase the space between line number and code. Other line number plugin is also acceptable. From this: to this:
ZIYIM's user avatar
  • 31
0 votes
1 answer
117 views

Discrete line numbers specified individually not as range

I was trying to find out if it is possible to give an ex command a list of lines instead of a range?
stmfunk's user avatar
  • 103
5 votes
1 answer
1k views

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

I found it strange that I can never have Vim show line number automatically for .py files, even if I have this as my ~/.vimrc set background=dark autocmd FileType py,c set number Strangely enough, ...
iBug's user avatar
  • 257
2 votes
1 answer
782 views

Set window-local option in every buffer/window

How do you set a window-local option (number) in literally every window/buffer? I was to bind <leader>t to toggle the number option in every buffer, using a global variable g:linum_status as ...
Greg Nisbet's user avatar
  • 1,859
3 votes
1 answer
356 views

Send file and line number to tmux

I want to send commands to tmux to run Elixir tests from vim. Using the % variable allows me to run the command to run a test for a single file. The relevant line in my .vimrc is nmap <silent> ...
nickcoxdotme's user avatar
-1 votes
1 answer
121 views

Prepend "number," to each line, where number is calculated from nth term

I have a file with 48 lines like 0.00000 0.00621 0.16298 0.19977 0.40198 0.29450 0.49277 0.28054 0.43256 0.18729 0.28934 And I want to prepend d.ddddddd, to each line, each d represents a digit (so ...
minseong's user avatar
  • 2,363
0 votes
2 answers
256 views

Open file at specified line number and automatically put that line in the middle of the screen?

How can Vim be configured to automatically centre a specified line number (eg. without manually having to use the zz command? So from the commandline I just want to issue: vim verylongfile.c +932 .....
Wossname's user avatar
  • 111
4 votes
1 answer
177 views

Sharing gutter space between line numbers and YCM markers

Is there a way, if the 'number' option is enabled to show line numbers, to make YouCompleteMe show errors and warnings by changing the line number colours instead of adding extra width to the gutter ...
realh's user avatar
  • 171
4 votes
1 answer
4k views

Get rid of extra gutter spacing

Vim always has 3 spaces for the line numbers on the left, in the gutter. Since I set relativenumber, and (unfortunately) don't have a monitor with the vertical space for 100 lines, I will never need ...
Eggrenade's user avatar
  • 101
7 votes
2 answers
2k views

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

I've turned on vim's relative line numbers, it starts from 0 but doing somthing like 10dd means I only get up to line 9, leaving the last one behind (becuase it's 10 including the current line). Yes, ...
Thermatix's user avatar
  • 249
7 votes
1 answer
3k views

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

I want Vim's sign column displayed to the right side of the line number column, I have it by default on the left. Here is a screenshot showing the sign column enabled and showing a + to indicate a ...
sushpa's user avatar
  • 71
2 votes
1 answer
419 views

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

I have previously asked this in StackOverflow (May 2015), but without getting any replies that I was completely happy with. This ought to be simple: I want to configure Vim to set number whenever ...
Kusalananda's user avatar
2 votes
2 answers
1k views

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

I have found this very useful function to turn on and off relative number lines: function! NumberToggle() if(&relativenumber == 1) set number else set relativenumber endif endfunc ...
Three Diag's user avatar
2 votes
1 answer
2k views

Vim ignore terminal color schemes when setting colors

I don't want vim to be affected by my terminal's color scheme. Is there a way to do this? In particular, I want my LineNr column to be colored black. I have seen it is possible because airline ...
minseong's user avatar
  • 2,363
2 votes
0 answers
389 views

How to display all line numbers in Vim?

In my .vimrc i have added this line set number But it only displays the line number for the lines that exist in the buffer, and not beyond this; after this it just shows ~. How can I show line ...
Ashok Arora's user avatar
8 votes
2 answers
1k views

Set line numbers only while in normal mode

I don't have much use for line numbers while in insert mode so I would like to turn them off. However they are great for normal mode. Constantly using set nu! is tiresome. Is there a way to tie set ...
Jason Basanese's user avatar
5 votes
1 answer
923 views

How to write each line into separate file?

I'd like to write content of the file into separate files each for each line. For example: Lorem ipsum dolor sit amet consectetur adipiscing elit I'd like to write 1st line into line1.txt, 2nd ...
kenorb's user avatar
  • 18.6k
6 votes
1 answer
2k views

Weird vertical bar to left of line numbers

Couldn't find anything on this by searching, so hopefully it's not super obvious. Every now and then, through some accidental sequence of keys, a solid bar appears to the left of my line numbers. I ...
Tyler Holden's user avatar
27 votes
3 answers
17k views

Replace a pattern with current line number

I'd like to replace 'x' in this file with current line number. That is, change x x x to 1 2 3 For now, I use a Perl one-liner: perl -pi -e '$x=$.; s/x/$x/' myfile.txt I think UltraEdit can do it ...
yong321's user avatar
  • 373
8 votes
0 answers
880 views

Highlight line number of folded lines

I want to have uniform highlighting of line numbers (provided by the LineNr and CursorLineNr hl-groups) but the line numbers of folded lines don't obey a particular group (as far as I know), but obey ...
Seninha's user avatar
  • 181
2 votes
2 answers
3k views

How to display line numbers in netrw v125 (vim7.0)?

I added let g:netrw_bufsettings = 'noma nomod nu nobl nowrap ro' and set nu to my vimrc on my Ubuntu machine. It can display line numbers in netrw (V149). When I use the same vimrc on a remote server ...
user3813057's user avatar
  • 1,481
4 votes
1 answer
1k views

Is there an option to zero-pad line numbers?

When using set number and set numberwidth I'd like to have the line numbers padded with zeros instead of spaces. example: 0001 0002 0003 Can it be done?
user1526370's user avatar
2 votes
2 answers
804 views

Extract line number as a variable to re-insert it

In insert-mode, I would like to extract the current line number I'm editing in a "variable"/memory/buffer, and to be able to paste it through a remapping. I know that :echo line(".") gives me the ...
Feffe's user avatar
  • 1,771
1 vote
1 answer
355 views

Vim 7.4 hybrid number mode not working

I recently discovered that Vim 7.4 enables a hybrid number mode, such that if you do set nu and set rnu, you'll see the absolute line number of the current line and relative line numbers everywhere ...
Ben Lindsay's user avatar
2 votes
1 answer
551 views

Why does relative line numbering sometimes turn off [closed]

I have vim set to relative line numbering with set number set relativenumber For some reason, every now and then, for some unknown reason, relative line numbering seems to turn off (or is stuck to ...
Ben Wainwright's user avatar
10 votes
4 answers
4k views

How can I set number and relativenumber at the same time?

I find both number and relativenumber useful. Is there any way to display them both at the same time?
Nathan Fellman's user avatar
5 votes
2 answers
656 views

Show only every n relative line number

Is it possible to show every n relative line numbers? So for example, I can see a a (+/-) 10, 20, 30... instead of a value on every line. If there's no current way to do it, is it possible to create?...
maged's user avatar
  • 195
6 votes
2 answers
1k views

Relative Numbers sidepanel with wrapped lines

I love the relative numbers side-column in vim but when I have wrapped lines it becomes inaccurate (or less usable since I can't use that number directly in a j/k command). I have nnoremap j gj in my ...
JZL003's user avatar
  • 263
8 votes
1 answer
174 views

How to get and use the number of each matched line in a global command

In his (very good) book "Pratical Vim" Drew Neil shows how to collect all the lines containing the word "TODO" into a register to use them latter. To do so he simply use a global command: :g/TODO/...
statox's user avatar
  • 50.1k
8 votes
1 answer
2k views

Current line number aligned to the left with number and relativenumber

I use relative line numbers along with an absolute line number for the current line: set number set relativenumber The absolute current line number is always aligned to the left, and the help pages (...
jviotti's user avatar
  • 183
5 votes
1 answer
776 views

Relative number on old Vim versions

How can I get the relative number feature on old Vim versions (7.2 to be exact in my scenario) ? I cannot install a newer version because other people are also using Vim on the same server.
JaDogg's user avatar
  • 417
5 votes
1 answer
324 views

How do I setnumber and relativenumber for :Explore in .vimrc

In my .vimrc I have set relativenumber and set number it works in the editor but not in :Explore. I have to set it manually every time. How can I always get set relativenumber and set number in :...
jnbdz's user avatar
  • 173
5 votes
2 answers
447 views

Different gutter colours for each code function

VIM knows to identify the start and end of code functions with the [[ and ]} commands. How might I use this to colour the gutters or line number backgrounds differently for each function? The issue ...
dotancohen's user avatar
21 votes
3 answers
5k views

How do I use relative line numbers in command line mode?

Recently I learned from Practical Vim a way to copy or move block of lines without having to move the cursor from the current position. This is done in command line mode. e.g. :123,133m. # moves ...
rpattabi's user avatar
  • 313
4 votes
2 answers
584 views

Can relative number be changed so that current line is 1?

I knew this site would teach me more about my beloved vim :-) In posting a question/answer on how to delete large blocks without having to count lines, one of the answers taught me something I didn't ...
user avatar
15 votes
4 answers
4k views

How can I search for a string between certain line numbers?

This is a problem I had recently. I have a file with several hundred lines of text. How can I search for a string between two specific line numbers? For e.g. I want to search between line numbers 100 ...
Seth's user avatar
  • 484
39 votes
5 answers
8k views

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

Starting from a blank slate, how can I obtain a document that contains 1 2 3 4 5 6 7 8 9 10 … 100 To be clear, I don't want these numbers displayed in the margin; I want them inserted into the ...
200_success's user avatar
  • 9,589
113 votes
4 answers
95k views

How can I show relative line numbers?

A lot of vim commands can take a number referring to the number of lines that the command will act on. Is it possible to show the line numbers relative to the current line? Something like the ...
Nick J Adams's user avatar
  • 1,295
45 votes
2 answers
12k views

How can I add line numbers to Vim?

I'd like to see line numbers, starting with 1 at the top, on the left side of Vim. Ideally it would look like this: 1 | foo = Foo.new 2 | bar = Bar.new 3 | baz = foo.baz(bar) ... 10| test = ...
user avatar

1
2