zhuang@linux:~/reading/practical-vim/08-navigate-inside-files-with-motions/$ less

Practical Vim / chapter 08

Navigate Inside Files with Motions

$ grep tags 08-navigate-inside-files-with-motions.md

This post extracts some knowledge from Chapter 8 – Navigate Inside Files with Motions.

CommandMove Cursor
jDown one real line
gjDown one display line
kUp one real line
gkUp one display line
0To first character of real line
g0To first character of display line
^To first nonblank character of real line
g^To first nonblank character of display line
$To end of real line
g$To end of display line
CommandMove Cursor
wForward to start of next word
bBackward to start of current/previous word
eForward to end of current/next word
geBackward to end of previous word

W B E gE for WORDS.

A word consists of a sequence of letters, digits, and underscores, or as a sequence of other nonblank characters separated with whitespace.

The definition of a WORD is simpler: it consists of a sequence of nonblank characters separated with whitespace.

Use WORD-wise motions if you want to move faster, and use word-wise motions if you want a more fine-grained traversal.

CommandEffect
f{char}Forward to the next occurrence of {char}
F{char}Backward to the previous occurrence of {char}
t{char}Forward to the character before the next occurrence of {char}
T{char}Backward to the character after the previous occurrence of {char}
;Repeat the last character-search command
,Reverse the last character-search command

use f and F in Normal mode, and t and T in Operator-Pending mode.

/pattern<CR>

Text ObjectSelectionText ObjectSelection
a) or abA pair of (parentheses)i) or ibInside of (parentheses)
a} or aBA pair of {braces}i} or iBInside of {braces}
a]A pair of [brackets]i]Inside of [brackets]
a>A pair of <angle brackets>i>Inside of <angle brackets>
a'A pair of 'single quotes'i'Inside of 'single quotes'
a"A pair of "double quotes"i"Inside of "double quotes"
a`A pair of `backticks`i`Inside of `backticks`
atA pair of <xml>tags</xml>itInside of <xml>tags</xml>

很多内置插件都采用 package 机制管理,matchit 通常被放在 opt 目录下,因此默认不会自动加载,需要手动:

vim 

KeystrokesCurrent contentKeystrokesCurrent content
iwwordawword plus space(s)
iWWORDaWWORD plus space(s)
issentenceassentence plus space(s)
ipparagraphapparagraph plus blank line(s)

As a general rule, we could say that the d{motion} command tends to work well with aw, as, and ap, whereas the c{motion} command works better with iw and similar.

The m{a-zA-Z} command marks the current cursor location with the designated letter.

'{mark} moves to the line where a mark was set, positioning the cursor on the first non-whitespace cahracter.

`{mark} command moves the cursor to the exact position where a mark was set, restoring the line and the column at once.

Automatic Marks as follows:

KeystrokesBuffer Contents
````Position before the last jump within current file
`.Location of last change
`^Location of last insertion
`[Start of last change or yank
`]End of last change or yank
`<Start of last visual selection
`>End of last visual selection

zhuang@linux:~/reading/practical-vim/08-navigate-inside-files-with-motions/$ comments