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:
\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.)
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
Here’s how vim-youcompleteme is installed/enabled on Ubuntu 14.04:
$ sudo apt-get install vim-addon-manager vim-youcompleteme
$ vam install youcompleteme
sudo apt-get install vim-puppet
ln -s /usr/share/vim/addons/syntax/puppet.vim ~/.vim/plugin/
In insert mode, backpace doesn’t delete characters as intended. To fix it add this to .vimrc: