13
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 ...
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 ...
11
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
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.
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 ...
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 ...
8
votes
Accepted
How to cut/trim line in statusline?
Values used in :set are strings. See :h set-args:
:set-args E487 E521
:se[t] {option}={value} or
:se[t] {option}:{value}
...
8
votes
Accepted
How to disable '-- INSERT --' text beneath statusline?
From the airline-FAQ:
How do i get rid of the default mode indicator?
Add set noshowmode to your vimrc.
8
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 ...
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
...
8
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 ...
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 ...
7
votes
Accepted
How to get rid of the command line bar?
No, it's impossible to hide the command-line.
-- EDIT --
You can prevent Vim from echoing "filename" XXXL, XXXC when editing a file by prepending silent to e:
:silent e foo
7
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:...
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 ...
7
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 ...
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 ...
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.
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'))
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 ...
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)...
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])
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 ...
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:
:...
6
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.
5
votes
Accepted
Swap command line and status-line?
What you call the "mode line" is actually called "command line".
You can't move it around.
You can't disable it.
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, ...
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 ...
5
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
...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
statusline × 149vimrc × 24
vimscript × 24
neovim × 13
plugin-airline × 11
buffers × 9
autocmd × 8
colorscheme × 7
ruler × 6
command-line × 5
gvim × 4
terminal × 4
filetype × 4
options × 4
variables × 4
plugin-lightline × 4
vim-windows × 3
highlight × 3
split × 3
counting × 3
regular-expression × 2
insert-mode × 2
microsoft-windows × 2
functions × 2
external-command × 2