| Previous Post | Top | Next Post |
TOC
This was originally written and created around 2013 and may require to be updated. (2021)
Vim basics
Learning and practice!
vimtutorvim +help +only
~/.vimrc as:
set nocompatible
set nopaste
set pastetoggle=<f2>
set syntax=ON
" Use secure modeline plug-in
set nomodeline
if $USER == "root"
set noswapfile
else
set swapfile
endif
" filler to avoid the line above being recognized as a modeline
" filler
" filler
Learn additional basics:
Additional vim commands (normal mode)
| command | meaning |
|---|---|
| :set tw=79 | textwidth to 79 |
| :set tw=0 | no textwidth |
| :set ai | autoindent == copy indent (non program) |
| :set noai | no autoindent |
| :set cin | cindent == C-like indent (K&R/Linux) |
| :set nocin | no cindent |
| :set ts=8 sts=4 et | C (K&R style tabstop) |
| :set ts=8 sts=0 noet | C (Linux style tabstop) |
| :set ts=8 sts=4 et | python (PEP-8 style tabstop) |
| :set syntax=ON | syntax highlighting ON based on filetype |
| :set syntax=OFF | syntax highlighting OFF |
| ^Y | 1 line screen up (yank one line) |
| ^E | 1 line screen down (extra line) |
| ^U | 1/2 page screen up (up) |
| ^D | 1/2 page screen down (down) |
| ^B | 1 page screen up (backward) |
| ^F | 1 page screen down (forward) |
| v | visual mode start for character select |
| V | visual mode start for line select |
| ^V | visual mode start for column select |
| :set fdm=manual | foldmethod manual |
| :set fdm=indent | foldmethod indent |
| :set fdm=syntax | foldmethod syntax |
| zc | fold close for the current line |
| zC | fold close for the current line (recursive) |
| zo | fold open for the current line |
| zO | fold open for the current line (recursive) |
| zm | fold more for the current document |
| zM | fold more for the current document (recursive) |
| zr | fold reduce for the current document |
| zR | fold reduce for the current document (recursive) |
| K | run man command on cursor |
| {Visual}= | indent selected range |
| :! | run |
| :r! | run and read |
| {Visual}! | run filter for visual mode |
For more, read vim help pages. I find followings especially interesting.
- |repeat.txt| repeating commands, Vim scripts and debugging
- |recover.txt| recovering from a crash
- |tagsrch.txt| tags and special searches
- |quickfix.txt| commands for a quick edit-compile-fix cycle
- |windows.txt| commands for using multiple windows and buffers
- |tabpage.txt| commands for using multiple tab pages
| Previous Post | Top | Next Post |