📄 motion.txt
字号:
gE Backward to the end of WORD [count] (inclusive).These commands move over words or WORDS. *word*A word consists of a sequence of letters, digits and underscores, or asequence of other non-blank characters, separated with white space (spaces,tabs, <EOL>). This can be changed with the 'iskeyword' option. *WORD*A WORD consists of a sequence of non-blank characters, separated with whitespace. An empty line is also considered to be a word and a WORD.Special case: "cw" and "cW" are treated like "ce" and "cE" if the cursor ison a non-blank. This is because "cw" is interpreted as change-word, and aword does not include the following white space. {Vi: "cw" when on a blankfollowed by other blanks changes only the first blank; this is probably abug, because "dw" deletes all the blanks}Another special case: When using the "w" motion in combination with anoperator and the last word moved over is at the end of a line, the end ofthat word becomes the end of the operated text, not the first word in thenext line.The original Vi implementation of "e" is buggy. For example, the "e" commandwill stop on the first character of a line if the previous line was empty.But when you use "2e" this does not happen. In Vim "ee" and "2e" are thesame, which is more logical. However, this causes a small incompatibilitybetween Vi and Vim.==============================================================================5. Text object motions *object-motions* *(*( [count] sentences backward (exclusive). *)*) [count] sentences forward (exclusive). *{*{ [count] paragraphs backward (exclusive). *}*} [count] paragraphs forward (exclusive). *]]*]] [count] sections forward or to the next '{' in the first column. When used after an operator, then the '}' in the first column. (linewise). *][*][ [count] sections forward or to the next '}' in the first column (linewise). *[[*[[ [count] sections backward or to the previous '{' in the first column (linewise). *[]*[] [count] sections backward or to the previous '}' in the first column (linewise).These commands move over three kinds of text objects. *sentence*A sentence is defined as ending at a '.', '!' or '?' followed by either theend of a line, or by a space or tab. Any number of closing ')', ']', '"'and ''' characters my appear after the '.', '!' or '?' before the spaces,tabs or end of line. A paragraph and section boundary is also a sentenceboundary.If the 'J' flag is present is 'cpoptions', at least two spaces have tofollow the punctuation mark; <Tab>s are not recognized as white space.The definition of a sentence cannot be changed. *paragraph*A paragraph begins after each empty line, and also at each of a set ofparagraph macros, specified by the pairs of characters in the 'paragraphs'option. The default is "IPLPPPQPP LIpplpipbp", which corresponds to themacros ".IP", ".LP", etc. (These are nroff macros, so the dot must be in thefirst column). A section boundary is also a paragraph boundary. Note thatthis does not include a '{' or '}' in the first column. Also note that ablank line (only containing white space) is NOT a paragraph boundary. *section*A section begins after a form-feed (<C-L>) in the first column and at each ofa set of section macros, specified by the pairs of characters in the'sections' option. The default is "SHNHH HUnhsh", which defines a section tostart at the nroff macros ".SH", ".NH", ".H", ".HU", ".nh" and ".sh".The "]" and "[" commands stop at the '{' or '}' in the first column. This isuseful to find the start or end of a function in a C program. Note that thefirst character of the command determines the search direction and thesecond character the type of brace found.If your '{' or '}' are not in the first column, and you would like to use "[["and "]]" anyway, try these mappings:> :map [[ ?{<CR>w99[{> :map ][ /}<CR>b99]}> :map ]] j0[[%/{<CR>> :map [] k$][%?}<CR>[type these literally, see |<>|]==============================================================================6. Text object selection *object-select* *text-objects* *v_a* *v_i*This is a series of commands that can only be used while in Visual mode orafter an operator. The commands that start with "a" select "a"n objectincluding white space, the commands starting with "i" select an "inner" objectwithout white space, or just the white space. Thus the "inner" commandsalways select less text than the "a" commands.These commands are {not in Vi}.These commands are not available when the |+textobjects| feature has beendisabled at compile time. *v_aw*aw "a word", select [count] words (see |word|). Leading or trailing white space is included, but not counted. *v_iw*iw "inner word", select [count] words (see |word|). White space between words is counted too. *v_aW*aW "a WORD", select [count] WORDs (see |WORD|). Leading or trailing white space is included, but not counted. *v_iW*iW "inner WORD", select [count] WORDs (see |WORD|). White space between words is counted too. *v_as*as "a sentence", select [count] sentences (see |sentence|). *v_is*is "inner sentence", select [count] sentences (see |sentence|). *v_ap*ap "a paragraph", select [count] paragraphs (see |paragraph|). *v_ip*ip "inner paragraph", select [count] paragraphs (see |paragraph|).a] *v_a]* *v_a[*a[ "a [] block", select [count] '[' ']' blocks. This goes backwards to the [count] unclosed '[', and finds the matching ']'. The enclosed text is selected, including the '[' and ']'.i] *v_i]* *v_i[*i[ "inner [] block", select [count] '[' ']' blocks. This goes backwards to the [count] unclosed '[', and finds the matching ']'. The enclosed text is selected, excluding the '[' and ']'.a) *v_a)*a( *v_ab* *v_a(*ab "a block", select [count] blocks, from "[count] [(" to the matching ')', including the '(' and ')' (see |[(|).i) *v_i)*i( *v_ib* *v_i(*ib "inner block", select [count] blocks, from "[count] [(" to the matching ')', excluding the '(' and ')' (see |[(|).a> *v_a>* *v_a<*a< "a <> block", select [count] <> blocks, from the [count]'th unmatched '<' backwards to the matching '>', including the '<' and '>'.i> *v_i>* *v_i<*i< "inner <> block", select [count] <> blocks, from the [count]'th unmatched '<' backwards to the matching '>', excluding the '<' and '>'.a} *v_a}*a{ *v_aB* *v_a{*aB "a Block", select [count] Blocks, from "[count] [{" to the matching '}', including the '{' and '}' (see |[{|).i} *v_i}*i{ *v_iB* *v_i{*iB "inner Block", select [count] Blocks, from "[count] [{" to the matching '}', excluding the '{' and '}' (see |[{|).When used after an operator:For non-block objects: For the "a" commands: The operator applies to the object and the white space after the object. If there is no white space after the object or when the cursor was in the white space before the object, the white space before the object is included. For the "inner" commands: If the cursor was on the object, the operator applies to the object. If the cursor was on white space, the operator applies to the white space.For a block object: The operator applies to the block where the cursor is in, or the block on which the cursor is on one of the braces. For the "inner" commands the surrounding braces are excluded. For the "a" commands, the braces are included.When used in Visual mode:When start and end of the Visual area are the same (just after typing "v"): One object is selected, the same as for using an operator.When start and end of the Visual area are not the same: For non-block objects the area is extended by one object or the white space up to the next object, or both for the "a" objects. The direction in which this happens depends on which side of the Visual area the cursor is. For the block objects the block is extended one level outwards.For illustration, here is a list of delete commands, grouped from small to bigobjects. Note that for a single character and a whole line the existing vimovement commands are used. "dl" delete character (alias: "x") |dl| "diw" delete inner word *diw* "daw" delete a word *daw* "diW" delete inner WORD (see |WORD|) *diW* "daW" delete a WORD (see |WORD|) *daW* "dd" delete one line |dd| "dis" delete inner sentence *dis* "das" delete a sentence *das* "dib" delete inner '(' ')' block *dib* "dab" delete a '(' ')' block *dab* "dip" delete inner paragraph *dip* "dap" delete a paragraph *dap* "diB" delete inner '{' '}' block *diB* "daB" delete a '{' '}' block *daB*Note the difference between using a movement command and an object. Themovement command operates from here (cursor position) to where the movementtakes us. When using an object the whole object is operated upon, no matterwhere on the object the cursor is. For example, compare "dw" and "da": "dw"deletes from the cursor position to the start of the next word, "da" deletesthe word under the cursor and the space after or before it.==============================================================================7. Various motions *various-motions* *m* *mark* *Mark*m{a-zA-Z} Set mark {a-zA-Z} at cursor position (does not move the cursor, this is not a motion command).m' or m` Set the previous context mark. This can be jumped to with the "''" or "``" command (does not move the cursor, this is not a motion command). *:ma* *:mark*:[range]ma[rk] {a-zA-Z} Set mark {a-zA-Z} at last line number in [range], column 0. Default is cursor line. *:k*:[range]k{a-zA-Z} Same as :mark, but the space before the mark name can be omitted. *'* *'a*'{a-z} To the first non-blank character on the line with mark {a-z} (linewise). *'A* *'0*'{A-Z0-9} To the first non-blank character on the line with mark {A-Z0-9} in the correct file (linewise when in same file, not a motion command when in other file). {not in Vi} *`* *`a*`{a-z} To the mark {a-z} (exclusive). *`A* *`0*`{A-Z0-9} To the mark {A-Z0-9} in the correct file (exclusive when in same file, not a motion command when in other file). {not in Vi} *:marks*:marks List all the current marks (not a motion command). {not in Vi}:marks {arg} List the marks that are mentioned in {arg} (not a motion command). For example:> :marks aB to list marks 'a' and 'B'. {not in Vi}A mark is not visible in any way. It is just a position in the file that isremembered. Do not confuse marks with named registers, they are totallyunrelated.'a - 'z lowercase marks, valid within one file'A - 'Z uppercase marks, also called file marks, valid between files'0 - '9 numbered marks, set from .viminfo file
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -