Vim
Usage⚑
Windows (split mode)⚑
Switch between windows⚑
Ctrl+w and the direction. Useful for vimdiff
.
Links⚑
Follow link⚑
Ctrl+]
Spell checking⚑
- To move to a misspelled word, use ]s and [s.
- To show suggestions use z=.
- To add a word to the dictionary use zg.
To mark a correct word as misspelled, use zw.
Set tabulation⚑
Execute set tabstop=2 shiftwidth=2 expandtab
and then, it's a good idea to execute :retab
.
Registers⚑
Vim saves the "clipboard" history as registers. You can check the saved ones with :reg
.
If you want to paste the content of one of them use "3p
for example.
Reference: superuser
Sort⚑
Vim has a very powerful built-in sort utility, or it can interface with an external one. In order to keep only unique lines and sort,
:{range}sort u
You can make a selection (with v
or V
for example) and then
:'<,'>sort u
Tips⚑
Go to th nth line⚑
[n]G
for example: 42G
.
Set filetype (useful for snippets)⚑
:set filetype=[filetype]
Disabling line numbers⚑
Useful for copying.
:set norelativenumber
Deleting trailing whitespaces automatically⚑
Add the following line to your .vimrc to automatically delete the trailing whitespaces when saving the file if it's one of the specific file types:
autocmd FileType c,cpp,java,php autocmd BufWritePre <buffer> %s/\s\+$//e
Breaking long lines automatically⚑
set textwidth=79
Change filetype based on directory path⚑
autocmd BufRead,BufNewFile [path regex] set syntax=html
Autoindent with tab as 4 spaces⚑
Set in .vimrc the following lines:
syntax enable
set smartindent
set tabstop=4
set shiftwidth=4
set expandtab
If you are working on a file and you want to indent it automatically from the beginning to the end use gg=G
.
Plugins⚑
Jedi⚑
davidhalter/jedi-vim uses the jedi Python autocompletion library for VIM.
Shortcuts⚑
- Completion
<C-Space>
- Goto assignment
<leader>g
(typical goto function) - Goto definition
<leader>d
(follow identifier as far as possible, includes imports and statements) - Goto (typing) stub
<leader>s
- Show Documentation/Pydoc
K
(shows a popup with assignments) - Renaming
<leader>r
- Usages
<leader>n
(shows all the usages of a name) - Open module, e.g.
:Pyimport os
(opens theos
module)
Syntastic⚑
Disable Syntastic⚑
:SyntasticToggleMode
CtrlP⚑
CtrlP changes working directory annoyingly⚑
Disable working path mode feature: let g:ctrlp_working_path_mode = '0'
UltiSnips and YouCompleteMe⚑
Since by default they both use
```vimrc " make YCM compatible with UltiSnips (using supertab) let g:ycm_key_list_select_completion = ['
" better key bindings for UltiSnipsExpandTrigger let g:UltiSnipsExpandTrigger = "
Reference⚑
Registers⚑
Plugins⚑
- vim-autoclose: enable an auto-close chars feature.