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
4
votes
1answer
611 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 ...
0
votes
1answer
27 views

line numbers in vim -H reversed

Recently I installed vim 8.2 on Windows 10 and vim 8.1.2269 on Linux Ubuntu. Both are compiled with +rightleft option. When I use gvim -H or vim -H (without vimrc file) and run :set number, I get line ...
0
votes
0answers
53 views

jump to line via letters instead of relative numbers

I currently use relative numbers to jump from my current line to another one. But since typing letters is easier then numbers, i wanted to know if there is a way to replace the line numbers with ...
1
vote
1answer
22 views

How to track down the code during debugging?

The problem I'm trying to troubleshoot now is specific to recent neovim 0.5.0 (exact version I'm using is NVIM v0.5.0-ef3230f35 but this issue reproduces in the same way on all my machines each ...
1
vote
0answers
36 views

Truncate line numbers when they are too large

So I'm using Vim's line numbering with set number set numberwidth=4 But I find that if line numbers exceed 999, then the gutter is automatically expanded to accommodate them. I actually don't want ...
0
votes
1answer
29 views

Line numbers relative to the screen

Is it possible to make Vim show line numbers relative to the screen? Not to the beginning of the file, and not to the current position of the cursor, but relative to the first line that is currently ...
1
vote
1answer
64 views

What are the benefits and use cases of relativenumber?

I have tried the relativenumber option several times, and I really don't get the point. People say that it's easier because they don't have to do the mental math of how many lines to go up or down ...
1
vote
1answer
89 views

How to toggle relative number for all opened windows?

I have this in my .vimrc: nnoremap <C-a> :set relativenumber!<cr> This toggles the relative number feature only in the current window. Is it possible to toggle it in all opened windows ...
2
votes
2answers
83 views

Set line number on chunks of file

Following an example such as: ##1## many text and lines ##z## ##2## more text ##z## ...etc How could i make the line number display only on chunks of text, inside of the ##digit## and the ##z## ...
1
vote
0answers
37 views

How to make Vim not be a line editor

Vim is famously (or infamously) a child of line-based editing. For many cases this is acceptable. But I wish to use it primarily as an academic tool with large amounts of text. I want the experience ...
1
vote
1answer
24 views

navigate lines with alphabets

I am using Programmer Dvorak layout. So typing numbers for navigation is not easy. Can I instead navigate with alphabetical characters showing up in place of relative numbers? Any other ideas?
0
votes
1answer
34 views

inserting a line number into substitution text

I have a long script file that I need to run in an application. I generally create these by running a query against the application and then creating the script I need using VIM. Sometimes these can ...
2
votes
0answers
98 views

Add vertical line between line numbers and file contents

I have set number in my ~/.vimrc, which enables line numbers. Generally they are quite useful, but it can be a bit tricky to discern the actual contents of a numerical data file from the line numbers, ...
2
votes
0answers
83 views

Vimdiff : highlight line numbers differently

I use relative line numbers thanx to the following settings in my vimrc: set number set relativenumber Since I don't want to wrap lines in diff mode, it's sometimes hard to tell which line include a ...
1
vote
0answers
49 views

Why is Neovim highlighting the cursor line numbers after the cursor has moved off?

I have turned on CursorLineNr highlighting as shown in this init.vim file. When I have my cursor on a line that wraps, it highlights all the individual "lines" on that line, as usual. However once my ...
0
votes
1answer
312 views

Highlight specific line numbers in the gutter

Can you target a spesific line number in the gutter? Let's say I want line 20 in the gutter te be red for some reason. Possible? Like CursorLineNr, but defining the line number yourself. In short I'm ...
0
votes
4answers
618 views

Nvim can not detect focus change inside tmux sessions

I use the following setting for automatic line number toggle. augroup numbertoggle autocmd! autocmd BufEnter,FocusGained,InsertLeave * set relativenumber autocmd BufLeave,FocusLost,InsertEnter ...
2
votes
1answer
95 views

Visual/Operator-pending autocommand?

Last week, I turned off 'number' and have been using only 'relativenumber', plus a line/column count in my status line. I don't really look at line numbers that much. But now I've had a radical idea. ...
3
votes
3answers
1k views

How to copy lines with line numbers?

I would like to copy several lines with line numbers; the text from set number isn't copied. Is there any way to do this?
0
votes
1answer
96 views

How can I keep the cursor position when piping the buffer through an external command?

I sometimes make shortcuts for myself, which run some external command on the current buffer, such as nnoremap <C-f> :%!clang-format -style=file<C-m> which formats the buffer with clang'...
3
votes
1answer
886 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, ...
3
votes
1answer
75 views

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

My experiments generate several log files, which I sometimes monitor manually. Some of the log files have an error message in the last line. I want to open all log files with the cursor located at ...
15
votes
4answers
2k 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 ...
2
votes
2answers
294 views

How to get line numbers of a different window

I would like to get these line numbers of a different window without moving to that window. line('w0') line('w$') line('.') line('$') As for the first two, we can use getwininfo([{winid}]) which ...
3
votes
2answers
487 views

Add line numbers and remove line numbers to selected lines

Based on the accepted answer of the following post How to add permanent line numbers to a file? I would like to have the capacity to select a certain number of lines and add numbers to those ...
0
votes
1answer
94 views

lines numbering and formatting

For practicing in vim I made: $ man bash > PracticeFile but upon setting up line numbers, using: :set nu the formatting got messed up, so that letters at the end of line are closer to number ...
7
votes
3answers
930 views

Visual Block Mode edit with sequential number [duplicate]

Suppose I'd like to create a list - "1" - "2" - "3" what Is the smartest way to create such? My attempt would be to i- "1"ESCyypp to get - "1" - "1" - "1" and then jump to the second line's 1 ...
0
votes
1answer
45 views

Why doesn't this `:execute` command work?

I was looking at this question on Unix & Linux Stack Exchange, and I thought I could write an answer for it using Vim. I ran the following for a quick test, and was surprised to find it didn't ...
0
votes
1answer
117 views

Enable line numbering for directories

When viewing a directory (using :Explore, for example), I would like to see line numbers. I can run :set number after opening the directory, and that works, but I can't get numbering to turn on by ...
4
votes
2answers
2k views

Show absolute and relative line numbers (not hybrid)

I'm trying to find a way to show relative line numbers as well as absolute line numbers, but not the way hybrid line numbers does it. I want to see both at all times, probably each displayed on a ...
2
votes
1answer
1k 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 ...
44
votes
2answers
9k 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 = ...
1
vote
1answer
86 views

excluding line numbering from mkview/loadview

I include set number in my .vimrc file to have line numbers automatically displayed upon opening a file. I also use the following code block to automatically save and load the view when closing and ...
0
votes
1answer
123 views

How to display a sign before the line number gutter?

I'd like to display some characters in left side of the line number gutter just like the vim-syntastic plugin does to show the errors. back when I was starting to learn vim I saw a plugin doing just ...
0
votes
1answer
597 views

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

I want to show line number in the editor, thus I use set nu in my vimrc. But when I open the embedded terminal with :ter, there are also line numbers there which I feel not comfortable. How could I ...
6
votes
2answers
682 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 ...
3
votes
2answers
959 views

Line number order is broken

I recently installed Neovim and SpaceVim. My line number order is broken: This occurs when working on any file, with both Vim and Neovim. How do I solve this? I'm a newbie to Vim and don't know how ...
0
votes
1answer
59 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 ...
1
vote
0answers
1k 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:
0
votes
1answer
75 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?
2
votes
1answer
209 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 ...
82
votes
4answers
33k 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 ...
3
votes
1answer
254 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> ...
-1
votes
1answer
101 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 ...
4
votes
1answer
148 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 ...
0
votes
2answers
148 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 .....
3
votes
1answer
2k 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 ...
5
votes
2answers
1k 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, ...
2
votes
1answer
173 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 ...
4
votes
1answer
222 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 :...