start_vim
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 cursoro
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) w
to move forward by word,b
to move back by worde
for end of word.0
to move to the beginning of the line,$
to move to the end of the linegg
to move to the beginning of the file,G
to move to the end of the file- line moves
- absolute distance from beginning
:10
to move to line 10 - reletive distance from current line
10j
to move down 10 lines,10k
to move up 10 lines - page moves
ctrl + d
to move down half a page,ctrl + u
to move up half a pagectrl + f
to move down a page,ctrl + b
to move up a page- find moves
f
to find a character on the line,;
to find the next instance of that character- e.g.
f
thena
to find the nexta
on the line F
is for backwards findt
is for find up to a characterT
is for backwards find up to a character
editing
x
to delete a character (making small changes in normal mode)dd
to delete a line
: for command mode
:q
to quit
v for visual mode
v
to enter visual mode- visual mode is for selecting text and then doing something (yp) with it
set up your vimrc file
vim ~/.vimrc
set number
to show line numbersset relativenumber
to show relative line numbers