131

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. ...


47

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 ...


44

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\ %B Gives you: 8984 2318 Another way is to use ga or the :ascii command. From :help ga: :as[cii] or ga :as :ascii ga ...


21

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 ...


21

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.


15

: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'


11

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 ...


8

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 ...


7

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


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

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 ...


6

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'...


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

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 ...


5

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 ...


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....


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

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


4

If you're really determined to do it, it can be done. A mostly accurate translation of the source function might look like this: function! Stl_P() let above = line('w0') - 1 let below = line('$') - line('w$') if below <= 0 return above ? 'Bot' : 'All' elseif above <= 0 return 'Top' else return printf('%2d%%'...


4

The problem is that there are various scenarios in which Vim will reload the colour scheme such as using :colorscheme or :syntax enable. Colour schemes should always start with :highlight clear to clear all existing highlight groups. Why? See what happens when you do: :highlight Test ctermfg=red :highlight Test ctermbg=blue What is Test now set to? To ...


4

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 ...


4

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') ...


3

A simple way (line number accuracy): function! LinePercent() return line('.') * 100 / line('$') . '%' endfunction Sample usage: :echo LinePercent() And with byte accuracy: function! BytePercent() let crt_byte = line2byte(line('.')) + col('.') - 1 let last_byte = line2byte(line('$')) + col(['$', '$']) - 1 return crt_byte * 100 / last_byte ...


3

If you save, you can then use :e again, to display that information. Also, you can use g Ctrl-g and/or Ctrl-g at any time to find out some (or the other) of the original info.


3

I have seen this problem in other plugins as well (and some take a LOT more than 0.04 seconds). The issue appears to be that Vim puts the terminal into "cooked" mode so that the command that is run can receive interrupt signals (from ctrl+c). This means that, for the duration of the command, your terminal is in line-editing mode. You can try this yourself ...


3

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


3

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 ...


3

I use: :f[ile] That is :f or :file. I'm surprised no one mention this in the answers, am I missing something?


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