How to view full path in statusline of Vim

This post shows how to quickly view the full path of the currently open file in Vim.

Some of you might like have the full path of file always be shown in the statusline. To do this set the %F item in the statusline. For example:

set statusline += '%F'

If you are using the vim-airline plugin, you can display the full path in its statusline by replacing the %f in its g:airline_section_c variable with %F. This post shows how you can view the current value of this variable.

Tried with: Vim 7.3 and Ubuntu 12.04 LTS

Advertisements

How to install and use the vim-airline plugin for Vim

Vim using vim-airline for statusline

vim-airline is a newer and lighter alternative to the vim-powerlinee plugin. It shows a beautiful and informative statusline in Vim.

Installation

The vim-airline plugin can beΒ installed for PathogenΒ by cloning itsΒ Github repository.

Fancy symbols

vim-airline can display those fancy symbols in the statusline in just a few steps:

  1. Download the powerline-fonts that have been patched to have the fancy powerline symbols.
  2. In the downloaded fonts, find the font that you use for your terminal and copy over those fonts to ~/.fonts
  3. Install the fonts using: fc-cache -vf ~/.fonts
  4. Once installed, configure your terminal to use these fonts. For GNOME Terminal, this can be done in Edit > Profile Preferences > General.
  5. Enable fancy symbols by adding this line to your vimrc: let g:airline_powerline_fonts=1

Tried with: Vim 7.3 and Ubuntu 12.04 LTS

How to install and use vim-powerline plugin for Vim

Statusline displayed by vim-powerline
Statusline displayed by vim-powerline

The statusline in Vim gets the job done: it shows the current mode and the location of the cursor in the currently open file. The vim-powerline plugin is a great way to jazz up the statusline of Vim and show lots of useful additional information. (As of this writing, folks are working on a new powerline plugin. This post is about the older vim-powerline plugin.)

Installation

The powerline plugin can be installed for Pathogen by cloning its Github repository.

Color support

The plugin uses lots of bright colors and needs 256-color support in Vim. One way to turn this on in Vim is by adding this line to your vimrc:

set t_Co=256

Fancy symbols

By default it shows a simple colored statusline. By using Unicode symbols, it can present a more beautiful statusline. To turn this on, add this line to your vimrc:

let g:Powerline_symbols = "fancy"

Patched fonts

The plugin can show symbols if the file is in version control (Git or Mercurial), for the filetype, for the line number and many more. For this to work, you need to patch your font and use that patched font for your terminal or Vim.

If you are on Ubuntu and using the default Ubuntu Mono font, then a patched version of this font can be obtained here. Follow the instructions on that page to install the fonts.

If you are on Windows and using Consolas, either directly or through SSH with PuTTY, I have more information in another post.

For other fonts and setups, use the script and directions in the fontpatcher directory.

Additional plugins

The plugin can show information on syntax errors and also version control information for Git and Mercurial. To view these status symbols and messages, install these three plugins: syntastic (for syntax checking), fugitive (for Git) and hgrev (for Mercurial).

With all this set up correctly, you get a Vim statusline that looks gorgeous and shows lots of useful information, both in terminal and GUI modes.

Tried with: Vim 7.3 and Ubuntu 12.04 LTS