266
votes
Accepted
How can I see the full path of the current file?
You can press {count}Ctrl-G:
{count}CTRL-G Like CTRL-G, but prints the current file name with
full path. If the count is higher than 1 the current
...
114
votes
How can I see the full path of the current file?
Register % contains the name of the current file.
The following commands could be entered to display the information shown:
:echo @% |" directory/name of file
:echo expand('%:t') |...
65
votes
Accepted
See the Unicode code point of the current character
You can use %b or %B in statusline or rulerformat. From :help statusline:
b N Value of character under cursor.
B N As above, in hexadecimal.
For example:
set statusline=%b\ 0x%B
Gives you:
...
34
votes
How can I see the full path of the current file?
You can use :!ls %:p to get the full path to the current file.
Depending on the ex context, % will either mean the contents of the file or the filename. When shelling out, it represents the file path ...
26
votes
Accepted
Jumping to a byte offset, and displaying position as byte offset
:goto 2356
jumps to the 2356th byte in the buffer.
Use the %o field in 'statusline' or 'rulerformat' to display the byte number of the character under your cursor.
Use %O to display the value in ...
23
votes
Accepted
How do I change the colour of the statusline of the currently focused window?
You can change it in your vimrc. The currently focused window is highlight group Statusline, other windows are StatuslineNC.
Example for terminal Vim:
hi StatusLine ctermfg=8 ...
16
votes
Accepted
Why do custom highlights in my vimrc get cleared or reset to default?
The problem is that many (all?) colorschemes will clear all highlights with highlight clear before setting their own colours. For example from /usr/share/vim/vim74/colors/peachpuff.vim:
" First ...
12
votes
How can I see the full path of the current file?
One can see the current working directory with :pwd. Of course, this is only the directory, and not the filename. To get the working directory and filename, we can use the special register %, which ...
10
votes
Accepted
`echon` for `echomsg`
This is not currently possible in Vim.
Internally, :echomsg is implemented as :execute, except that when invoked as :echomsg the result of execution is displayed with the attribute of the last :...
10
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 ...
10
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 ...
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 ...
8
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
8
votes
How can I see the full path of the current file?
There are aleady better answers, but if (for some reason) you wanted to use the shell to get the full path of the file (this is more useful if you're going to perform some other operation on the file ...
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
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 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
8
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 ...
7
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 ...
7
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
...
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
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 ...
7
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
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 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.
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
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 ...
6
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 ...
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])
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
statusline × 130vimscript × 24
vimrc × 19
plugin-airline × 10
buffers × 9
neovim × 7
autocmd × 7
colorscheme × 6
command-line × 4
gvim × 4
variables × 4
ruler × 4
terminal × 3
vim-windows × 3
highlight × 3
filetype × 3
split × 3
options × 3
counting × 3
regular-expression × 2
insert-mode × 2
microsoft-windows × 2
functions × 2
external-command × 2
plugin-system × 2