vim¶
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:
indent multiple lines by n spaces¶
n is 2 in this example
select multiple lines with v (visual mode) and do > or < to go the other way
another way:
- select the lines you want with
V, hit:and dole4where 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¶
- press
control + vto go into visual block mode - select your lines, either with the arrow keys or
j/k - press
shift + istart whatever you want to prepend, like#to comment something out - press
ESC
convert tabs to spaces¶
that's correct.
create new file¶
create new file while vim is open:
paste from external clipboard¶
vertical highlighting¶
search¶
search and replace within the whole document:
search and replace interactively term by term:
useful plugins¶
nerdtree¶
switch to nerdtree window¶
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
with this line you can toggle nerdtree with \f given that \ is your leader key.
reload tree¶
or reload the whole folder structure:
vimwiki¶
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
vim-markdown¶
- vim-markdown docs - until I've learned it by myself
vimoutliner¶
- vimoutliner docs here - until i've learned it
- vimoutliner cheat sheet - they're really tricking you in reading the README to find the cheat sheet!