- End of the file:
shift + g - Next line:
j - Go down a defined number of lines:
number + j - Skip to next word:
w - Skip back a word:
b - Skip to next section:
W - Skip back to previous section:
B - Go to end of the line:
$ - Go to beginning of the line:
0 - Go to top of the screen:
shift + h - Go to bottom of the screen:
shift + l - Forward multiple words:
5w - Forward multiple letters:
5l - Back multiple letters:
5h - Forward to the next 'y':
fy(case sensitive) Ctrl-dmove half-page downCtrl-umove half-page upCtrl-bpage upCtrl-fpage down
- Undo:
u - Redo:
ctrl + r - Inserting text where the cursor is:
i - Inserting text at the start of the line:
I - Insert at the end of the line:
shift + a - Copy entire line:
yy or Y - Copy word:
yw - Paste copied line:
p - Paste from System Clipboard:
"+P - Change multiple words:
5cw - Insert at the end of the line:
A - Append at end of word:
ea - Insert at beginning of word:
bi - Copy whole line to system clipboard (on mac os):
"*yy
- d will delete current and left character
- d$ will delete from current position to end of line
- d^ will delete from current backward to first non-white-space character
- d0 will delete from current backward to beginning of line
- dw deletes current to end of current word (including trailing space)
- db deletes current to beginning of current word
dt#{insert_character}will delete up to but not including the characterdf#{insert_character}will delete up to and including the character- Delete current line: dd
- Join the line below: shift + j
- Delete entire word: cw
- Delete to the end of the line: shift + C
- Delete multiple lines: d + number of lines + enter
- Delete from current position to a specific line number: dG
- Deleting all items in a file that start with a pattern: :g/< search term>/d
- Deleting all lines that are empty or that contain only whitespace: :g/^\s*$/d
- Select the entire line: V
- Select a range of text: v
- Select a column: control + v
- Reselect a block: gv
- Select all: ggVG
- %s/pattern/text to replace
- Save the file: :w
- Save the file and quit: :wq
- Quit without saving: :q!
- Use horizontal split: :sp filename
- Use vertical split: :vsp filename
- Switch from top to bottom: control + w + j
- Switch from left to right: control + w + l
- Switch from bottom to top: control + w + j
- Switch from right to left: control + w + h
- Open file in vertical pane:
conrol + v
- Open file in vertical pane:
s - Open file and don't move focus it (preview it):
go
- While on current line: f +
- Search for word in file: /word + enter
- Find next search result: n
- Search backwards: N
- Go to first result: ggn
- Go to last result: GN
- To remove search highlighting: :noh
- Normal
- Insert
- Visual
- Replace
- Command Line
- :e filename - Edit a file in a new buffer
- :bnext (or :bn) - go to next buffer
- :bprev (of :bp) - go to previous buffer
- :bd - delete a buffer (close a file)
- :sp filename - Open a file in a new buffer and split window
- ctrl + ws - Split windows
- ctrl + ww - switch between windows
- ctrl + wq - Quit a window
- ctrl + wv - Split windows vertically
:qaclose all open vim windows:wqasave work in all tabs and quit:lsshow all files in buffer (open)
- Fix indenting when pasting: set paste in .vimrc file
- Indenting: visual mode
+ >or< - Repeat indenting:
.(The period repeats the last action done)
- Comment: visual block select with CTRL-V then I# (insert # in the begining)
- Uncomment: visual block select with CTRL-V then X (delete the first symbol on the line)
- Changing multiple lines of text: control + v + shift + i + action + esc
- Select elements in paragraph: v + / + content
- Turning on line numbers: :set nu
- Turning on syntax highlighting: :syntax on
cd
mv .vimrc .vimrc-old
mv .vim .vim-old
touch .vimrc; mkdir .vim
- To get help: :h
- To exit help: :bd
c + i + twill remove the code between HTML tags, such as:<div>Some content</div>c + i + }will remove the code inside of a JavaScript function
:! <your command here>
<ctrl> + z- View "open files" with
jobs - open job with
fg - open specific job with
fg %<specific job number>
qr- Do the actions you want repeated
- hit escape and then
q 3@rthe number can change for how many times you want to repeat
grep '<seach_term>' **/*.<file_type>use-ifor case insensitive search
:grep -ir '<search_term>' .. This willl open the first matched pattern, to browse through them use:cnand:cp. To see the quick list use:copenand:ccloseto close the quickfix list.
w !node
- Annotate every line:
,b - Annotate marked lines:
,n - Clean up annotations:
,c
- Go to file path:
gf - Look for keyword in required files:
[I