1 2 3 4 5 6 7 |
filetype plugin indent on " show existing tab with 4 spaces width set tabstop=4 " when indenting with '>', use 4 spaces width set shiftwidth=4 " On pressing tab, insert 4 spaces set expandtab |
Category Archives: vim
Shortcuts: Ctrl q to exit vim
I really like this tip to exit vim quickly.
You can use ZZ to save and exit vim but it’s 3 keystrokes. This neat hack lets you do the same in just 2 keystrokes. On the Mac:
~/.bash_profile
1 2 3 |
bind -r '\C-s' stty -ixon |
~/.vimrc
1 2 3 4 5 6 |
inoremap <C-s> <esc>:w<cr> " save files nnoremap <C-s> :w<cr> inoremap <C-d> <esc>:wq!<cr> " save and exit nnoremap <C-d> :wq!<cr> inoremap <C-q> <esc>:qa!<cr> " quit discarding changes nnoremap <C-q> :qa!<cr> |
https://unix.stackexchange.com/a/241784/198669
vim tips
Indent multiple lines quickly
Use >
e.g. to indent 5 lines use:
5>>
To mark a block of 3 lines and indent in vim, use:
Vjj>
http://stackoverflow.com/questions/235839/how-do-i-indent-multiple-lines-quickly-in-vi
Repeat last change
Use .
e.g. if deleting a word with dw
then just hit .
to repeat.
http://vim.wikia.com/wiki/Repeat_last_change
Split screen and view another file
:vsplit <file>
https://www.cs.oberlin.edu/~kuperman/help/vim/windows.html