π List of shortcuts which I used working with Vim
- Ctrl + w = - reset windows into best width & height
- Ctrl + w h - move focus - to left window
- Ctrl + w j - move focus - to down window
- Ctrl + w k - move focus - to up window
- Ctrl + w l - move focus - to rigth window
- Ctrl + w > - resize window - descrese width size
- Ctrl + w < - resize window - increase width size
- Ctrl + w - - resize window - increase size
- Ctrl + w + - resize window - decrease size
- {number}Ctrl + w _ - set window height which is set to {number} lines
- Ctrl + w _ - maximize in height
- Ctrl + w | - maximize in width
- Ctrl + w H - move focused window to the far left
- Ctrl + w J - move focused window to the bottom
- Ctrl + w K - move focused window to the top
- Ctrl + w L - move focused window to the far right
:e FILENAME- open file to edit, replaced current window with file:tabe(:tabedit) - open file in new tab:tabc(:tabclose) - close current tab
:noh(:nohl,:nohlsearch) - clear highlight after search/foo- searching textfooin whole document (forwards)?foo- searching textfooin whole document (backwards):cw- show result list after searching:%s/foo/bar/g- replace globallyfootobar*- searching word where cursor is on it (forwards)#- searching word where cursor is on it (backwards)g*- searching partial words where cursor is on it (forwards)g#- searching partial words where cursor is on it (backwards)/\<foo- searching words starting withfoo/foo\>- searching words ending withfoo/\<foo\>- searching wordsfoo
so ~/.vimrc- reload configuration in opened editor:retab- replace current whitespaces with sets in.vimrcfile:!ls- run commandlsin shell- Ctrl + a - increment number
- Ctrl + x - decrement number
- ZZ - write files and quit
- ZQ - quit all instances of vim
- Ctrl + z - hide Vim to background - use
fgin terminal to bring it to foreground - Ctrl + l - redraw Vim windows
au VimEnter * NERDTree- auto open NERDTree plugin in each editor instance
map <F9> :NERDTreeToggle <CR>- show/hide NERDTree panel on press<F9>
m{char}- save current position into{char}- `{char} - go to saved mark
:marks- display list of current saved markers
- Ctrl + e - scroll the window down
- Ctrl + y - scroll the window up
- Ctrl + f - scroll down one page
- Ctrl + b - scroll up one page
H- move cursor to the top of the viewportM- move cursor to the middle of the viewportL- move cursor to the bottom of the viewportgg- move cursor to the top of fileG- move cursror to the bottom of file{- move cursor to previous empty line}- move cursor to next empty line%- jump between bracket in line30%- move cursor to line which is 30% of the top of filezz- center verticaly line with cursor``- back cursors to previous place- Ctrl + ^ - return to previous file
{command}{text object or motion}
Example:
diw- "delete in word" - remove single word when cursor is on itcaw- "change all word" (grap the whitespace)ciw- remove word and enter to insert modeci}- remove text in parentheses and enter to insert modecit- remove text in HTML tagsyi)- yank text inside parenthesesva"- visually select all inside doublequotes (including doublequotes)vi"- likeva"but without doublequote
d- delete (also cut)c- change (delete, then place in insert mode)y- yank (copy)v- visual select
w- wordss- sentencesp- paragraphst- tags (available in XML/HTML files)
a- alli- int- 'tilf- find forwardF- find backward
q{char}- start recording(do the things)q- exit from recording
@{char}
The best way is put them to file (~/.vimrc). Default path for configuration.
syntax on- enable syntax highlightingcolorscheme molokai- set editor themeset number- enable line numberset noic- don't ignore letter case, ex. in searchingset expandtab- change tabulators to spacesset tabstop=4- number of characters as indent with TAB keyset shiftwidth=4- number of characters as indent with insertionsset mouse=a- enable mouse in editorset background=dark- little change for brighter colorsset autoindent- enable automatic indentionset hlsearch- enable highlighting after searching processset incsearch- run searching process after you press any char (after '/')set nowrapscan- stop navigate throught search result when file is endsset nowrap- don't wrap linesset clipboard=unnamedplus- Vim use the same buffer as OSset guifont=Inconsolata\ 12- change font in editor
Google Chrome plugin which support Vim navigation in browser.
More description in article [PL]: http://piecioshka.pl/blog/2015/01/23/vimium-plugin-do-twojej-przegladarki.html
Aside panel with directory structure. Some useful shortcuts:
q- exitA- maximize window- Ctrl + c - change current highlighted directory as root
- Ctrl + u - change current directory as parent
- Ctrl + p - set focus on parent dir on NERDTree list
- Ctrl + o - on dir: open list with files; on file: edit file
- s - open file in vertical split mode
- i - open file in horizontal split mode
Comment line with simple
- \cc - comment line (recognized filetype and comment in current lang)
- \c[SPACE] - toggle comment
- \cu - remove comment
- \cs - comment line in multiline mode
- \cy - yank line and comment it
- \c$ - comment from cursor to end of line
- \cA - put comment delimiters and set cursor between them
Search in: files, buffers. Some shortcuts:
- Ctrl + f - move base of searching into left side (switch between modes)
- Ctrl + b - move base of searching into right side
- Ctrl + r - search by regexp mode
- Ctrl + j - like
jin file (move cursor in search list down) - Ctrl + k - like
k - Ctrl + t - open selected file in new tab
- Ctrl + x - open selected file in half horizontal window
- Ctrl + v - open selected file in half vertical mode
- http://walking-without-crutches.heroku.com/ - textmate vs. vim - useful presentation
- http://walking-without-crutches.heroku.com/image/images/vi-vim-cheat-sheet.png - cool cheat sheet
- http://vimcasts.org/ - video cast about Vim
- http://www.vim.org/docs.php - full Vim documentation
- http://www.cs.swarthmore.edu/help/vim/ - tips and tricks with Vim
- https://www.maketecheasier.com/vim-keyboard-shortcuts-cheatsheet/
- https://gist.github.com/awidegreen/3854277
- https://www.computerhope.com/unix/vim.htm
- https://github.com/gmarik/vundle - plugin manager for Vim
- https://github.com/ctrlpvim/ctrlp.vim - show window with last modified files
- https://github.com/scrooloose/nerdtree - NERDTree support editor for projects navigation
- https://github.com/ervandew/supertab - show suggest after
<tab>press - https://github.com/scrooloose/syntastic - check syntax after save file
- https://github.com/bling/vim-airline - show fancy chars in bottom bar, some arrows etc.
- https://github.com/majutsushi/tagbar - show outline of methods in file
- https://github.com/tpope/vim-surround - add possibility to wrap string with smth
- https://github.com/Townk/vim-autoclose - if you put '(' this plugin automatically puts ')'
- https://github.com/airblade/vim-gitgutter - show plus/minus when you make changes
- https://github.com/matze/vim-move - can move up/down current line
- https://github.com/mattn/emmet-vim - plugin for emmet - successor of zen-coding
- https://github.com/scrooloose/nerdcommenter - comments line
- https://github.com/tpope/vim-markdown - highlighter for *.md files
- https://github.com/tpope/vim-fugitive - shortcuts for Git commands
You can always use this:
:h quickref:h SHORTCUT(:h dd,:h :s):exusage- open help window and scroll toEX commands(very useful when you try check meaning of all Vim commands)
Happy coding! β€οΈ