Skip to content


I'll never get used to it. Let's get started and learn..

save with sudo

I need it every day, I just can't remember it. needs to be on the top. when you get this (opening and editing a file as a regular user but the file is owned by someone else): 'readonly' option is set (add ! to override), do this:

:w !sudo tee %

indent multiple lines by n spaces

n is 2 in this example

set shiftwidth=2

select multiple lines with v (visual mode) and do > or < to go the other way

another way:

  1. select the lines you want with V, hit : and do le4 where 4 is the number of spaces

(V for visual mode, jj for selecting two lines (you can also use your arrow keys), :le4 to indent by 4 spaces)

prepend text / multiple cursors

  1. press control + v to go into visual block mode
  2. select your lines, either with the arrow keys or j / k
  3. press shift + i start whatever you want to prepend, like # to comment something out
  4. press ESC

convert tabs to spaces

that's correct.

:set tabstop=4 shiftwidth=4 expandtab

create new file


create new file while vim is open:


paste from external clipboard

Ctrl + Shift + V

thank you.

vertical highlighting

ctrl + v

thank you.

search and replace within the whole document:


search and replace interactively term by term:


useful plugins


switch to nerdtree window

ctrl + ww

toggle nerdtree window

open, close, open, close. bed up, bed down, bed up, bed down

that's the default:


add something like this to your `~/.vimrc`` file

nnoremap <Leader>f :NERDTreeToggle<Enter>

with this line you can toggle nerdtree with \f given that \ is your leader key.

reload tree


or reload the whole folder structure:



a plain text wiki for vim including a diary function, kinda cool.

key bindings

I need to learn and remember them! <Leader> is \

  • <Leader>ww -- Open default wiki index file.
  • <Leader>wt -- Open default wiki index file in a new tab.
  • <Leader>ws -- Select and open wiki index file.
  • <Leader>wd -- Delete wiki file you are in.
  • <Leader>wr -- Rename wiki file you are in.
  • <Enter> -- Follow/Create wiki link
  • <Shift-Enter> -- Split and follow/create wiki link
  • <Ctrl-Enter> -- Vertical split and follow/create wiki link
  • <Backspace> -- Go back to parent(previous) wiki link
  • <Tab> -- Find next wiki link
  • <Shift-Tab> -- Find previous wiki link

diary key bindings:

  • <Leader>w<Leader>w - create new diary file with current date
  • <Leader>wi - go to diary index
  • <Leader>w<Leader>i - update diary index



convert newline to unix