Tag Archives: vim

Remove trailing whitespace with VIM

Here’s a quick tip on how to get rid of unwated trailing whitespace using vim.

Let’s say, I have the following code:

Open that file with vim. The following command deletes any trailing whitespaces.


Here’s the screenshot of the text after removing the whitespace:

In search, \s finds whitespace (a space or tab). \+ finds one or more occurences. $ matches the end of line, finally e flag means no error is displayed.

Ref: Remove unwanted spaces (warning: this reference page contains lots of ads, probably avoid opening it on a mobile device.)

How to toggle between buffers in Vim with vim-airline

First if you haven’t yet heard about vim-airline plugin, and you’re a Vim user, you owe it to yourself to check it out.

By default vim-airline displays the opening buffers on the top part of the window.

So how to navigate between those buffers? Well, according to this, it seems those buffers are for visual only. To navigate between them, we can use :bp for previous buffer, and :bn for next buffer. Alternatively, we can use :ls to list all buffers, then navigate to a particular buffer by running :number (substitute number with an actual number).

However, if you know any better or more elegant ways to switch between the opening buffers, please do share!


I need to setup vim-youcompleteme to get real-time completion for golang code.

Assuming that this part has been completed first:

$ cd ~/.vim/bundle
$ git clone https://github.com/fatih/vim-go.github

Ref: http://blog.gopheracademy.com/vimgo-development-environment/

Here’s how vim-youcompleteme is installed/enabled on Ubuntu 14.04:

$ sudo apt-get install vim-addon-manager vim-youcompleteme
$ vam install youcompleteme

Ref: http://weichong78.blogspot.com.au/2014/06/vim-to-ubuntu-1404-youcompleteme.html