170

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 buffer number is also given. Pressing 1 followed by Ctrl+G shows the full path of the current file. If {count} is higher than 1, the buffer name will also be shown. ...


70

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') |" name of file ('tail') :echo expand('%:p') |" full path :echo expand('%:p:h') |" directory containing file ('head') If all that is wanted is to display ...


53

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: 8984 0x2318 Another way is to use ga or the :ascii command. From :help ga: :as[cii] or ga :as :ascii ga ...


23

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 relative to the current directory. The command '%:p' will add the full path filename modifier to %. There are a few other interesting filename modifiers such ...


22

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 ctermbg=2 cterm=NONE hi StatusLineNC ctermfg=2 ctermbg=8 cterm=NONE For the GUI, use guifg and guibg.


17

: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 hexadecimal format. Reference: :help :goto :help 'statusline' :help 'rulerformat'


13

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 remove all existing highlighting. set background=light hi clear if exists("syntax_on") syntax reset endif let colors_name = "peachpuff" hi Normal guibg=PeachPuff ...


9

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 :echohl and saved to the message list (reference src/eval.c functions ex_echohl and ex_execute), which is how you get any color on a saved message. The actual ...


8

Values used in :set are strings. See :h set-args: :set-args E487 E521 :se[t] {option}={value} or :se[t] {option}:{value} Set string or number option to {value}. ... White space between {option} and '=' is allowed and ...


8

From the airline-FAQ: How do i get rid of the default mode indicator? Add set noshowmode to your vimrc.


8

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 contains information about the current file. If you use :echo @%, you'll get the directory and filename of the current file. If you use :echo expand('%:p'), you'...


7

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


6

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 run that once. Then when VIing a document type :set laststatus=2 <ENTER> :set statusline+=%F <ENTER>


6

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 result displayed. Here, your expression would be: &iminsert==1?'GREEK':'LATIN' The syntax of this expression is described in :help expr1; if the test ...


6

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 set stl+=%{SubName()} let prev_sub_line_num = search('subroutine ', 'bcnW') Call the search() function to look for the pattern subroutine. In the 2nd ...


6

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 foldmethod to indent because it works well with python. (But I guess using marker or manual would work too) Open a split which will contain the "context information"...


6

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 vimrc set shortmess-=S or activate it on demand with :se shm-=S Following additional information can be found under :h search-commands When 'shortmess' ...


6

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 in case of a function call do: function! GetEditor() return $EDITOR endfunction Now, suppose you still need a system() function call, because you need to ...


6

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 expected behavior. However when you source your config again, nothing empties the variable so you keep adding duplicate values to it. Thus you probably want to ...


5

What you call the "mode line" is actually called "command line". You can't move it around. You can't disable it.


5

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 with the shell), on a Unix-like system you could run: :!realpath % or: :'<,'>!realpath % to insert the path into the document over the current ...


5

%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, that when using tabs, the virtual column number is an approximation of your current column number as if you were using spaces instead of tabs. *This answer is an ...


5

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:mylocaloption = 'mylocalvalue' When you use the :set command, the value you assign to the option can contain characters which have a special meaning on the command-line....


5

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 value of this option influences when the last window will have a status line: 0: never 1: only if there are at least two windows 2: always So in ...


5

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])


5

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 in the output of your echo command. To get rid of that terminating newline, use substitute(): let s:name = substitute(system("echo $EDITOR"), '\n', '', 'g') ...


5

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 plain if let l:is_git_dir = trim(system('git rev-parse --in-inside-work-tree')) if l:is_git_dir is# 'true' let g:git_branch = trim(system('git rev-parse --...


5

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: :hi StatusLine StatusLine xxx term=bold,reverse cterm=bold,reverse ctermfg=0 ctermbg=15 gui=bold,reverse You'll see the cterm=bold,...


4

This is controlled with the shortmess option. In particular, you probably want to set the O (upper-case o) flag with set shortmess+=O. O message for reading a file overwrites any previous message. Also for quickfix message (e.g., ":cn"). Note that this is included in the Vim default, which is filnxtToO. So I think you either added this to your ...


4

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


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