📄 insert.txt
字号:
<S-Right> cursor one word forward (like "w" command) *i_<S-Right>*<C-Right> cursor one word forward (like "w" command) *i_<C-Right>*<Home> cursor to first char in the line *i_<Home>*<End> cursor to after last char in the line *i_<End>*<C-Home> cursor to first char in the file *i_<C-Home>*<C-End> cursor to after last char in the file *i_<C-End>*<LeftMouse> cursor to position of mouse click *i_<LeftMouse>*<S-Up> move window one page up *i_<S-Up>*<PageUp> move window one page up *i_<PageUp>*<S-Down> move window one page down *i_<S-Down>*<PageDown> move window one page down *i_<PageDown>*<MouseDown> scroll three lines down *i_<MouseDown>*<S-MouseDown> scroll a full page down *i_<S-MouseDown>*<MouseUp> scroll three lines up *i_<MouseUp>*<S-MouseUp> scroll a full page up *i_<S-MouseUp>*CTRL-O execute one command, return to Insert mode *i_CTRL-O*-----------------------------------------------------------------------Note: If the cursor keys take you out of Insert mode, check the 'noesckeys'option.The CTRL-O command sometimes has one side effect: If the cursor was beyond theend of the line, it will be put on the last character in the line.The shifted cursor keys are not available on all terminals.When the 'whichwrap' option is set appropriately, the <Left> and <Right>keys on the first/last character in the line make the cursor wrap to theprevious/next line.==============================================================================3. 'textwidth' and 'wrapmargin' options *ins-textwidth*The 'textwidth' option can be used to automatically break a line before itgets too long. Set the 'textwidth' option to the desired maximum linelength. If you then type more characters (not spaces or tabs), thelast word will be put on a new line (unless it is the only word on theline). If you set 'textwidth' to 0, this feature is disabled.The 'wrapmargin' option does almost the same. The difference is that'textwidth' has a fixed width while 'wrapmargin' depends on the width of thescreen. When using 'wrapmargin' this is equal to using 'textwidth' with avalue equal to (columns - 'wrapmargin'), where columns is the width of thescreen.When 'textwidth' and 'wrapmargin' are both set, 'textwidth' is used.If you don't really want to break the line, but view the line wrapped at aconvenient place, see the 'linebreak' option.The line is only broken automatically when using insert mode, or whenappending to a line. When in replace mode and the line length is notchanged, the line will not be broken.Long lines are broken if you enter a non-white character after the margin.The situations where a line will be broken can be restricted by addingcharacters to the 'formatoptions' option:"l" Only break a line if it was not longer than 'textwidth' when the insert started."v" Only break at a white character that has been entered during the current insert command. This is mostly Vi-compatible."lv" Only break if the line was not longer than 'textwidth' when the insert started and only at a white character that has been entered during the current insert command. Only differs from "l" when entering non-white characters while crossing the 'textwidth' boundary.If you want to format a block of text, you can use the "gq" operator. Type"gq" and a movement command to move the cursor to the end of the block. Inmany cases, the command "gq}" will do what you want (format until the end ofparagraph). Alternatively, you can use "gqap", which will format the wholeparagraph, no matter where the cursor currently is. Or you can use Visualmode: hit "v", move to the end of the block, and type "gq". See also |gq|.==============================================================================4. 'expandtab', 'smarttab' and 'softtabstop' options *ins-expandtab*If the 'expandtab' option is on, spaces will be used to fill the amount ofwhitespace of the tab. If you want to enter a real <Tab>, type CTRL-V first.The 'expandtab' option is off by default. Note that in Replace mode, a singlecharacter is replaced with several spaces. The result of this is that thenumber of characters in the line increases. Backspacing will delete onespace at a time. The original character will be put back for only one spacethat you backspace over (the last one). {Vi does not have the 'expandtab'option} *ins-smarttab*When the 'smarttab' option is on, a <Tab> inserts 'shiftwidth' positions atthe beginning of a line and 'tabstop' positions in other places. This meansthat often spaces instead of a <Tab> character are inserted. When 'smarttabis off, a <Tab> always inserts 'tabstop' positions, and 'shiftwidth' is onlyused for ">>" and the like. {not in Vi} *ins-softtabstop*When the 'softtabstop' option is non-zero, a <Tab> inserts 'softtabstop'positions, and a <BS> used to delete white space, will delete 'softtabstop'positions. This feels like 'tabstop' was set to 'softtabstop', but a real<Tab> character still takes 'tabstop' positions, so your file will still lookcorrect when used by other applications.If 'softtabstop' is non-zero, a <BS> will try to delete as much white space tomove to the previous 'softtabstop' position, except when the previouslyinserted character is a space, then it will only delete the character beforethe cursor. Otherwise you cannot always delete a single character before thecursor. You will have to delete 'softtabstop' characters first, and then typeextra spaces to get where you want to be.==============================================================================5. Replace mode *Replace* *Replace-mode* *mode-replace*Enter Replace mode with the "R" command in normal mode.In Replace mode, one character in the line is deleted for every character youtype. If there is no character to delete (at the end of the line), thetyped character is appended (as in Insert mode). Thus the number ofcharacters in a line stays the same until you get to the end of the line.If a <NL> is typed, a line break is inserted and no character is deleted.Be careful with <Tab> characters. If you type a normal printing character inits place, the number of characters is still the same, but the number ofcolumns will become smaller.If you delete characters in Replace mode (with <BS>, CTRL-W, or CTRL-U), whathappens is that you delete the changes. The characters that were replacedare restored. If you had typed past the existing text, the characters youadded are deleted. This is effectively a character-at-a-time undo.If the 'expandtab' option is on, a <Tab> will replace one character withseveral spaces. The result of this is that the number of characters in theline increases. Backspacing will delete one space at a time. The originalcharacter will be put back for only one space that you backspace over (thelast one). {Vi does not have the 'expandtab' option}==============================================================================6. Virtual replace mode *vreplace-mode* *Virtual-replace-mode*Enter Virtual replace mode with the "gR" command in normal mode.Virtual replace mode is similar to Replace mode, but instead of replacingactual characters in the file, you are replacing screen real estate, so thatcharacters further on in the file never appear to move.So if you type a <Tab> it may replace several normal characters, and if youtype a letter on top of a <Tab> it may not replace anything at all, since the<Tab> will still line up to the same place as before.Typing a <NL> still doesn't cause characters later in the file to appear tomove. The rest of the current line will be replaced by the <NL> (that is,they are deleted), and replacing continues on the next line. A new line isNOT inserted unless you go past the end of the file.Interesting effects are seen when using CTRL-T and CTRL-D. The charactersbefore the cursor are shifted sideways as normal, but characters later in theline still remain still. CTRL-T will hide some of the old line under theshifted characters, but CTRL-D will reveal them again.As with Replace mode, using <BS> etc will bring back the characters that werereplaced. This still works in conjunction with 'smartindent', CTRL-T andCTRL-D, 'expandtab', 'smarttab', 'softtabstop', etc.In 'list' mode, Virtual replace mode acts as if it was not in 'list' mode,unless "L" is in 'cpoptions'.Note that the only times characters beyond the cursor should appear to moveare in 'list' mode, and occasionally when 'wrap' is set (and the line changeslength to become shorter or wider than the width of the screen), ormomentarily when typing over a CTRL character. A CTRL character takes up twoscreen spaces. When replacing it with two normal characters, the first willbe inserted and the second will replace the CTRL character.This mode is very useful for editing <Tab> separated columns in tables, forentering new data while keeping all the columns aligned.{Vi does not have Virtual replace mode}==============================================================================7. Insert mode completion *ins-completion*In Insert and Replace modes, there are several commands to complete part of akeyword or line that has been typed. This is useful if you are usingcomplicated keywords (e.g., function names with capitals and underscores).These commands are not available when the |+insert_expand| feature wasdisabled at compile time.Completion can be done for:1. Whole lines |i_CTRL-X_CTRL-L|2. keywords in the current file |i_CTRL-X_CTRL-N|3. keywords in 'dictionary' |i_CTRL-X_CTRL-K|4. keywords in the current and included files |i_CTRL-X_CTRL-I|5. tags |i_CTRL-X_CTRL-]|6. file names |i_CTRL-X_CTRL-F|7. definitions or macros |i_CTRL-X_CTRL-D|8. keywords in 'complete' |i_CTRL-N|All these (except 2) are done in CTRL-X mode. This is a sub-mode of Insertand Replace modes. You enter CTRL-X mode by typing CTRL-X and one of theCTRL-X commands. You exit CTRL-X mode by typing a key that is not a validCTRL-X mode command. Valid keys are the CTRL-X command itself, CTRL-N (next),and CTRL-P (previous).Also see the 'infercase' option if you want to adjust the case of the match.Note: The keys that are valid in CTRL-X mode are not mapped. This allows for":map ^F ^X^F" to work (where ^F is CTRL-F and ^X is CTRL-X). The key thatends CTRL-X mode (any key that is not a valid CTRL-X mode command) is mapped.The following mappings are suggested to make typing the completion commandsa bit easier (although they will hide other commands): :inoremap ^] ^X^] :inoremap ^F ^X^F :inoremap ^D ^X^D :inoremap ^L ^X^LCompleting whole lines *compl-whole-line* *i_CTRL-X_CTRL-L*CTRL-X CTRL-L Search backwards for a line that starts with the same characters as in the current line before the cursor. Indent is ignored. The found line is inserted in front of the cursor. CTRL-L or CTRL-P Search backwards for next matching line. This line replaces the previous matching line. CTRL-N Search forward for next matching line. This line replaces the previous matching line. CTRL-X CTRL-L After expanding a line you can additionally get the line next to it by typing CTRL-X CTRL-L again, unless a double CTRL-X is used.Completing keywords in current file *compl-current* *i_CTRL-X_CTRL-P* *i_CTRL-X_CTRL-N*CTRL-X CTRL-N Search forwards for words that start with the keyword in front of the cursor. The found keyword is inserted in front of the cursor.CTRL-X CTRL-P Search backwards for words that start with the keyword in front of the cursor. The found keyword is inserted in front of the cursor. CTRL-N Search forward for next matching keyword. This keyword replaces the previous matching keyword. CTRL-P Search backwards for next matching keyword. This keyword replaces the previous matching keyword. CTRL-X CTRL-N or CTRL-X CTRL-P Further use of CTRL-X CTRL-N or CTRL-X CTRL-P will copy the words following the previous expansion in other contexts unless a double CTRL-X is used.If there is a keyword in front of the cursor (a name made out of alphabeticcharacters and characters in 'iskeyword'), it is used as the search pattern,with "\<" prepended (meaning: start of a word). Otherwise "\<\k\k" is usedas search pattern (start of any keyword of at least two characters).In Replace mode, the number of characters that are replaced depends on thelength of the matched string. This works like typing the characters of thematched string in Replace mode.If there is not a valid keyword character before the cursor, any keyword ofat least two characters is matched. e.g., to get: printf("(%g, %g, %g)", vector[0], vector[1], vector[2]); just type: printf("(%g, %g, %g)", vector[0], ^P[1], ^P[2]);Multiple repeats of the same completion are skipped; thus a different matchwill be inserted at each CTRL-N and CTRL-P (unless there is only onematching keyword).Single character matches are never included, as they usually just get inthe way of what you were really after. e.g., to get: printf("name = %s\n", name); just type: printf("name = %s\n", n^P); or even: printf("name = %s\n", ^P);The 'n' in '\n' is skipped.After expanding a word, you can use CTRL-X CTRL-P or CTRL-X CTRL-N to get theword following the expansion in other contexts. These sequences search forthe text just expanded and further expand by getting an extra word. This isuseful if you need to repeat a sequence of complicated words. Although CTRL-P
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -