#vim
shift Vselect line, up or down select linesshift >shift select block or line outshift <shift select block or line indto delete highlighted text and copy to cliboardDdelete everything after cursor to end of lineyto copy (yank)pto paste after cursor,Pbeforeuundo last change.repeat last command$ vim +linenumber file.copen file and jump to that line numbergggo to first line,GGgo to lastgtgo to next tab{i}gtgo to tab number{i}:tabmmove current tab to last tab:tabm {i}move current tab to position{i}:tabslist all tabs including their displayed windows:tabfirstgo to first tab:tablastgo to last tabUconvert SELECTED text to uppercase (alsogU)uconvert SELECTED text to lowercase (alsogu)~toggle SELECTED text to opposiste case (alsog~)control lto refresh vim when changes happen (likegit pull)- Use
*to go to the definition of the word under the cursor - In NERDTree,
shift Topens select file in new tab behind current - In NERDTree,
topens selected file in new tab :set syntax=phpor:set syntax=yamlor:set syntax=perletc.:set nowrapturn off word wrap:%s/$/',/search the entire file%s, find end of line$and replace with',s/' .*/'/search the selection for'if found, replace it and the rest of the line with'%s/ ->\zs .*//keep the arrow, delete all after arrow%s/ -> .*//delete the arrow and everything aftervim scp://url/path/remote_fileedit remote file locally, saving to remote- Find this or that or blue
this\|that\|blue - Sort selection alphabetically:
sort, reversesort! - Folding: in
.vimrcaddlet php_folding = 1 - Folding:
zato toggle foldzAto toggle all - If
command rand loose arrow-key, thenctrl zand typefgon the command line d0delete every thing before cursor in visual modectrl uto delte every thing befor cursor in insert modeereload current file:retabset all tabs in current file to current settings. Good for files that used tabs, not spaces.:vertical resize 30to resize the current window to exactly 30 characters wide.
%create a new filedcreate a new directoryRrename the file/directory under the cursorDDelete the file/directory under the cursor
To select a column, or even a block: In normal mode (press ESC),
control v- select column
shift I- enter your comment syntax, like
# - press
ESC
To delete a column:
control i- select column
dwill delete (and copy to clipboard,pto paste)
After copying (yanking) a block of text, can also select another block of text and paste over it. Similar to other editors gui's.
My basic .vimrc file:
syntax on
set bs=2
set expandtab
set tabstop=2
set shiftwidth=2
set number
" extra
" remove white spaces at end of line
:nnoremap <silent> <F4> :let _s=@/<Bar>:%s/\s\+$//e<Bar>:let @/=_s<Bar>:nohl<CR>
" Format visually selected JSON
:vnoremap <F8> :!python -m json.tool<CR>