Vim
09 Jun 2014
Tags:
vim
·
Tutorial
Enter to Vim
vim . # open with file browse
vim -c "h quickref | only"
vim -O < file1 > < file2 > ... # open in verticle
vim -o < file1 > < file2 > ... # open in honzital
Normal Mode
Save, Exit
Keys |
Description |
ZZ |
save and quit |
ZQ |
save without quit |
Movements
Keys |
Description |
w[ord] |
{letters, numbers, underscore} |
W[ORD] |
{non-blank characters} |
g{motion} |
work with display line ex. gj down one line, g$ go to end of display line |
f{char} |
move to next char |
t{char} |
move to before next char |
; |
repeat last search |
, |
repeat last search backward |
Jump
Keys |
Description |
% |
jump between open/close parentheses |
<C-o>, <C-i> |
toggle jump position |
{num}|(pipe) |
Go to Column |
<number>G |
go to line number |
Visual
Keys |
Description |
v{motion} |
visual mode select in line |
V{motion} |
visual mode select line |
<C-v>{motion}{cIA} |
change/insert/append in multiple lines |
<C-v>{motion}: |
command with multiple lines |
Indent
Keys |
Description |
== |
Auto Indent |
= |
Auto Indent in selected on visual mode |
J |
join the current line and next line together |
Edit
Keys |
Description |
cw |
change word |
gu{motion}, gU{motion} |
lower/upper letter |
Delete
Keys |
Description |
daw |
delete a word |
das |
delete a sentence |
dap |
delete a paragraph |
dW |
delete until space |
dG |
delete until end of file |
d$ |
delete until last of line |
dbw , <C-w> in insert mode |
delete back one word |
d^ , <C-u> in insert mode |
delete back to start of line |
Undo
Keys |
Description |
u |
redo |
<C-r> |
Redo |
Search
Keys |
Description |
\<word>\c |
search word with ignore case |
Repeat
Keys |
Description |
. |
repeat last action (not include any move action) |
ETC
Keys |
Description |
* |
highlight word |
<C-a>,<C-x> |
addition and subtraction on numbers that also find next number automatically if current cursor not a number |
<C-I> |
Tab |
<C-[> |
Esc |
<C-M> |
Enter |
<C-H> |
Backspace |
In Insert Mode
Keys |
Description |
<C-r>=55*10<Cr> in insert mode |
calculate can print it |
Windows Managements
Windows Split
Keys |
Description |
<C-ws> |
Split windows |
<C-wv> |
Split windows vertically |
<C-wq> |
Quit windows |
<C-ww> |
switch between windows |
You split navigations with
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
Tab
Command |
Description |
:tabe[dit] {filename} |
open file in new tab use gt, gT to move to next, previous tab |
:tabc[lose] |
close all tabs |
:tabo[nly] |
keep current tab and closing all others |
Vim spell
Command |
Description |
:set spell |
enable spell checker |
[s, ]s |
jump to miss spelling work |
z= |
fix miss spelling word |
zg |
add current word into spell dictionary |
zw |
remove current word from spell dictionary |
Repositioning the screen
Command |
Description |
zt |
Move current line to top screen |
zz |
Move current line to mid screen |
zb |
Move current line to bottom screen |
Keys |
Description |
<C-f> |
scroll down one screen |
<C-b> |
scroll up one screen |
<C-d> |
scroll down half screen |
<C-u> |
scroll up half screen |
Text object <need to combine with cmd>
Keys |
Description |
iw/aw |
inside/around word |
is/as |
inside/around sentences |
ip/ap |
inside/around paragraph |
it/at |
inside/around tag ex. html tag |
i” |
inside double quote |
i) |
inside parents |
Register
# update vim version
$ brew install vim
$ brew install reattach-to-user-namespace
Command |
Description |
:reg[ister] |
check buffer register |
”<register>p |
paste buffer |
”<register>yy |
yank to buffer |
”*yy |
yank to system clipboard |
Vim Script
- autocmd group
Open vim without plugin no settings from your .vimrc
Open vim without plugin
Reference:
- A vim Tutorial and Primer
- วิธีใช้ Vi และ Vim
- How to Use Vim’s Spell checker
- Vi/Vim Cheat Sheet
- Vim Cheat Sheet Graphical
- Vim & Tmux & System Clipboard
- vim.rc & vim plugin (video th)
- John Crepezzi’s Vim (video)
- Vi and Vim Macro Tutorial: How To Record and Play
- VIM Grammar-Jaa-LGyagRA
- Vim tips: Folding fun
- Learn Vimscript the Hard Way
- Vim as an IDE
- How to jump directly to a column number in Vim
17.Coming Home to Vim
- Vim-LanguageTool
- Vim Tips (KKLUG)
- Vim multiline editing like in sublimetext?
- A Good Vimrc
- THE VIM PRESENTATION
- Vim Cast
- vim-galore - Everything you need to know about Vim.
- Converting tabs to spaces