copy and paste from missing semester
how to learn vim
Here’s how you learn a new editor:
- Start with a tutorial (i.e. this lecture, plus resources that we
point out)
- Stick with using the editor for all your text editing needs (even if
it slows you down initially)
- Look things up as you go: if it seems like there should be a better way to do something, there probably is
vim modes
i for insert mode
from normal mode: - i to enter insert mode at the cursor
- o to enter insert mode on the next line
esc for normal mode (from insert mode)
- normal mode is for viewing and editing text ### moving around
- moving my cursor around using
h,j,k,l(left, down, up, right) wto move forward by word,bto move back by wordefor end of word.0to move to the beginning of the line,$to move to the end of the lineggto move to the beginning of the file,Gto move to the end of the file- line moves
- absolute distance from beginning
:10to move to line 10 - reletive distance from current line
10jto move down 10 lines,10kto move up 10 lines - page moves
ctrl + dto move down half a page,ctrl + uto move up half a pagectrl + fto move down a page,ctrl + bto move up a page- find moves
fto find a character on the line,;to find the next instance of that character- e.g.
fthenato find the nextaon the line Fis for backwards findtis for find up to a characterTis for backwards find up to a characterediting
xto delete a character (making small changes in normal mode)ddto delete a line
: for command mode
:qto quit
v for visual mode
vto enter visual mode- visual mode is for selecting text and then doing something (yp) with it # set up your vimrc file
vim ~/.vimrcset numberto show line numbersset relativenumberto show relative line numbers