gruckion / learning

Learning stuff
0 stars 0 forks source link

Vim and bash shortcuts #35

Open gruckion opened 5 years ago

gruckion commented 5 years ago

Cheat sheet

% move between ([{ }]) V select mode

G go to line

0 start of line $ end of line i insert mode o insert mode with new line dd delete line u undo ctrl r redo w jump to next word b jump to previous word . dot command repeats last command cw deletes a word ci t | { | < " will delete content within the edge element

:sp split screen ctrl ww to move between windows shift zz :vsp filename

BASH ctrl u cut input ctrl y paste ctrl o entrers and keeps the text in command ctrl l clears terminal

gruckion commented 5 years ago

These are notes compiled from this video.

Verbs in Vim

d => Delete c => Change (delete and enter insert mode)

=> Indent < => Outdent v => visual select y => Yank (copy) p => Paste

Using dw will delete a word, but using cw will delete the word and put you into insert mode. So you and replace a word "bob" with "hello" by using cw hello using . will then repeat that operation.

Nouns in Vim - Motions

w => word (forward by a word) b => back (back by a word) 2j => 2 lines down (repeats j twice)

If you are in the middle of a word you want to operate on then you will need to use text objects.

Nouns in Vim -- Text Objects

iw => "inner word" (works from anywhere in the word) it => "inner tag" (the content inside of an HTML tag) i" => "inner quotes" ip => "inner paragraph" as => a sentence

Nouns in Vim -- Parameterised Text Objects

f, F => "find" the next character (f forward | F backwards) t, T => "find /,? => Search (up to the next match)

Can the dot command repeat the change I am trying to make? If not then I am probably doing something wrong. Vim is a very expressive language, if I am unable to express my change in it, it is probably me not Vim.

Try to use text-objects over motions, i.e. movements between objects such as { [ ( " < e.t.c rather than motions.