VIM: use sudo to write file

If you should use sudo but didn’t use it for some reason before editing some file, you can still activate sudo from inside the vim after editing (in order to be able to save the file):

:w !sudo tee %

This will do the same as if you’d first run

sudo vim somefile

and then edit the file..

VIM: use sudo to write file

VIM: get specific filetype benefits when working with new file

Just a small tip, let’s say you use Sparkup plugin for vim, which allows you to benefit from robust html markup writing, but you created a new file and as filetype is not yet set, it will not work, untill you save your file as *.html, however you can always set filetype manually, like so:

:set ft=html

and Sparkup will be loaded so you can write HTML markup fast even before saving the file

I wonder if there is any better way to accomplish this.

VIM: get specific filetype benefits when working with new file

VIM: text indent multiple times

Here are few techniques that allows to shift selected text more than once:
1)

press ESC
press “v” to enter visual mode
select text
SHIFT plus “>” twice
press “.” to repeat last indent

2)

press ESC
press “v” to enter visual mode
select text
SHIFT plus “>” twice
press “g” then “v” and use any indent you require

In order to automate this method add following to your .vimrc file:

vnoremap < <gv
vnoremap > >gv

VIM: text indent multiple times