Skip to main content
Share Your Experience: Take the 2024 Developer Survey
15 votes

How to display in the statusline the number of matches from a search?

vim 8.1.1270 (May 2019) :set shortmess-=S Since May 2019 vim offers the possibility to show the count in the statusline (as long as it less than 99) which however is disabled by default. Add to your ...
Hotschke's user avatar
  • 4,780
12 votes

Jumping to a byte offset, and displaying position as byte offset

You can hit g Ctrl+g and you get the full information about the position: Col 13 of 35; Line 18 of 2272; Word 70 of 7767; Char 410 of 50021; Byte 410 of 50118
Vivian De Smedt's user avatar
11 votes

How to get rid of the command line bar?

I finally found a way to get rid of the command, mode as well as file name in the command line bar! at the bottom of your .vimrc: set noshowmode " to get rid of thing like --INSERT-- set noshowcmd ...
某Leo's user avatar
  • 111
9 votes
Accepted

Conditional strings on the statusline

From :help 'statusline': The result can contain %{} items that will be evaluated too. So if you write an expression inside %{} and add it to your 'statusline' option, it should be evaluated and the ...
saginaw's user avatar
  • 6,796
9 votes

How can I see the full path of the current file?

The following will display the path relative to your current directory: :f[ile] That is :f or :file.
Cédric Van Rompay's user avatar
9 votes

How can I see the full path of the current file?

You need to set your status line to be viewable and also set it to path. I did so permanently by adding the two lines below to my ~/.vimrc set laststatus=2 set statusline+=%F If you want to just ...
user34612's user avatar
  • 191
9 votes
Accepted

My statusline is missing. How do I get it back?

Your statusline depends on statusline for "what" to display on the status line. See :h statusline But you also have an option to control "when" to display the status line: From :h laststatus: The ...
nobe4's user avatar
  • 16.1k
9 votes
Accepted

How to remove ^@ character returned by `system()`?

The ^@ is a NUL character, 0x00, which Vim uses in certain cases to store a newline, 0x0a. Unix commands usually terminate their output with a newline, and the system() function captures that newline ...
garyjohn's user avatar
  • 6,349
8 votes
Accepted

Display current subroutine/subprogram in statusline

You could try the following code: function! SubName() abort let prev_sub_line_num = search('subroutine ', 'bcnW') return matchstr(getline(prev_sub_line_num), 'subroutine \zs\w\+') endfunction ...
user9433424's user avatar
  • 6,148
8 votes
Accepted

How do I conditionally add items to the statusline?

There are 2 ways to change the value of an option, with the :set or :let command. :set myoption=myvalue :setlocal mylocaloption=mylocalvalue Or: :let &myoption = 'myvalue' :let &l:...
user9433424's user avatar
  • 6,148
8 votes
Accepted

Carets in status line

This is the standard behaviour of Vim. If StatusLine and StatusLineNC have the same highlighting, the program will use the caret character (^) in the status line of the current window (in order to ...
Shamaoke's user avatar
  • 241
8 votes

How to remove ^@ character returned by `system()`?

You got an answer already. However, for your specific case, you don't need the system() call, since you want an environment variable to be expanded. In that case you could simply use echo $EDITOR or ...
Christian Brabandt's user avatar
7 votes
Accepted

How to display file size in vim rulerformat?

You can get the size of the buffer in bytes with: :echo line2byte('$') + len(getline('$')) line2byte() gets the number of bytes until the last line, but not including the last line, so we need to ...
Martin Tournoij's user avatar
7 votes
Accepted

Default rulerformat

The default format of the ruler option is directly set in the C core of Vim. If you do not like the default, you can customize it using the 'rulerformat' option and using the statusline format ...
Christian Brabandt's user avatar
7 votes
Accepted

Statusline wrong column count for multi-byte characters

Well, it looks the answer is as simple as :set statusline=%v That uses the virtual column number instead of the column number. Thanks to D. Ben Knoble for pointing me in the right direction.
Quasímodo's user avatar
  • 2,466
6 votes

How can I see the full path of the current file?

To show the full path for all files, including resolved symlinks, use the following. :echo resolve(expand('%:p'))
joelostblom's user avatar
6 votes

How to get rid of the command line bar?

In Vim 9.0.0114–9.0.0339 and Neovim 0.8 (prerelease), set cmdheight=0 hides the command line. Zero cmdheight was removed in Vim 9.0.0340.
Cyrus Yip's user avatar
  • 251
6 votes
Accepted

Keep beginning of current fold on top of the screen

So following the idea I suggested in comments here is what I've come up with: First let's demonstrate it with a gif (I'm not sure why the cursor leaves this ugly mark): The idea is to: Set the ...
statox's user avatar
  • 50.1k
6 votes
Accepted

Show filename tail and parent directory in statusline

You can include arbitrary expressions in your status line with %{}. Try this: :set statusline=%{expand('%:p:h:t')}/%t This finds the tail of the head of the full path (i.e. just the parent directory)...
Rich's user avatar
  • 32.1k
6 votes

How to display in the statusline the number of matches from a search?

If you use the vim-airline Plugin together with the vim-anzu Plugin, the search statistics are already displayed in the statusline. See the below screenshot (and note the [1/3])
Christian Brabandt's user avatar
6 votes
Accepted

How to get the current mode in vim?

You are looking for the function mode(), see :h mode(): mode([expr]) Return a string that indicates the current mode. If [expr] is supplied and it evaluates to a non-zero Number or ...
statox's user avatar
  • 50.1k
6 votes
Accepted

Sourcing vimrc duplicates statusline in nvim

When you use the += operator, you actually ask vim to append some new values to the statusline variable. When you first open Vim statusline is set to an emtpy value so adding %.35f to it give you the ...
statox's user avatar
  • 50.1k
6 votes
Accepted

ctermbg and ctermfg are backwards or incorrect for certain highlighting groups

You're probably overlooking the additional attributes set in the cterm= field for those highlights. For instance, after I set ctermfg=black ctermbg=white for StatusLine, I get this when I query it: :...
filbranden's user avatar
  • 29k
5 votes
Accepted

Difference between `virtual column number` and `column number` in statusline

%c -- column number, i.e. byte number. %v and %V -- virtual column number, i.e. column number on your screen. So what is the difference between the actual and virtual column number? The answer is, ...
Ashok Arora's user avatar
5 votes

Status line: Display path to file in the buffer, *without* filename

Maybe you could use the following: set statusline= " Path to file (head) set statusline+=%{expand('%:h')}/ " Switch color set statusline+=%#Keyword# " File name (tail) set statusline+=%t %{} allows ...
user9433424's user avatar
  • 6,148
5 votes

Review: git branch in statusline

The most general improvements I can give are to avoid the long ?: and to make use of the get function on dictionaries. For example, I would write return get(g:, 'git_branch', '') For the if, use a ...
D. Ben Knoble's user avatar
  • 26.4k
5 votes
Accepted

Disable Lightline on Nerdtree

It's a hack, but you could try this: augroup filetype_nerdtree au! au FileType nerdtree call s:disable_lightline_on_nerdtree() au WinEnter,BufWinEnter,TabEnter * call s:...
user938271's user avatar
  • 5,987
5 votes
Accepted

How to get Vim to show git status in the statusline?

The easiest way would be to call git inside %{} like so: let &statusline = '%{substitute(system("git status -s"), "\n", " ", "g")}' Anything inside %{} get ...
Martin Tournoij's user avatar
5 votes
Accepted

How to add the "filetype" to the default "statusline" in Vim?

Simple status line: filename and filetype As you can see with :set statusline?, the default 'statusline' option is empty in vim. You'll need to overwrite it. Here's the most simple example with ...
Biggybi's user avatar
  • 2,770
5 votes

How to prevent whitespace associated with items in the statusline from taking up space, when the item is not shown?

Yes, it's parentheses (aka "item group"). Sort of let &statusline = '%f%( %r%)%( %y%)' Some time ago I also wrote a plugin (actually a function) to assist in building status line ...
Matt's user avatar
  • 20.8k

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