linux learning 23 Linux operation and maintenance of the necessary skills -vim Editor efficient use of Advanced

A, vim line mode

  1, address and bound

    a、:start_pos[,end_pos]

      # # Of a particular row, i.e., e.g., line 5 5

      : Current line

      $: The last line;

      #, #: Specified line range, starting from the left line, the right end of the line;

      # + #: Specified line range, the left side of the absolute number of start line, the right side is offset relative to the line numbers on the left side;

        For example: 3 + 7: starts from the third row, and then add seven rows.

           ., $ - 1: Indicates the current line to the penultimate line

           1, $: that the full text can also be expressed in%

      / Pattern /: first started to be matched from the cursor to the end of the file specified by the mode line

        / First /, $: indicates a match from the current cursor starts for the first time to be first to the last row of the beginning of the end

      / Pat1 /, / pat2 /: starting from the cursor position to the first match line from the beginning to the pat1 all lines between the end of the first match line to a pat2

    B, may be used together with the edit command, for carrying out editing operation

      d

      Y

      c

      w / PATH / TO / SOMEFILE: the range of the text to the specified file stored;

      r / PATH / FROM / SOMEFILE: the specified text file is read and inserted into the designated location

  2. Find

    / PATTERN: Find all strings that can be matched to the current mode from the current cursor location to the end of the file

    ? PATTERN: Find all strings can be matched to the current mode from at the current cursor to the header file

      n: Next, the command in the same direction

      N: a, opposite to direction command

  3, Find and Replace

    a, s command line mode; and using the format:

      s / content to find / replace as content / modifiers

        Things to look for: You can use regular expressions

        Replace the contents: You can not use regular expressions, but can be referenced;

          If "looking for content" part symbol grouping mode, after use in the "Replace Content" in the reference;

          Pattern matching to find a direct reference to the full text

        Modifiers:

          i: ignore case;

          g: global replace, meaning a row of matches many times, then replace all

            

          FIG mean: 1,20 represents delimitation, i.e., rows 1-20, behind s / this / This / into this shows a replacement This, however, only the first alternative to match. If you want each row are replaced each occurrence if need be written as s / this / This / g. If you do not case sensitive when this alternative i.e. any case characters are replaced This needs to be written s / this / This / ig

      The separator may be replaced with other character is used:

        s@@@

        s###

        Example: Replace all text with the word beginning with a lowercase t replace all uppercase

          %s@\<t\([[:alpha:]]\+\)\>@T\1@g

0:33:08

Guess you like

Origin www.cnblogs.com/Presley-lpc/p/12099447.html