The command ' vim ' and how to use it

Source: Internet
Author: User

Vim Basic editing commands
There are three basic modes of 1.vim:
Edit mode (command mode), input mode, last line mode
2. Three modes of conversion:
Edit mode--Input mode
I:insert, enter at the cursor position
A:append, enter after cursor location
O: Opens a new line below the line where the current cursor is located
I: Input at the beginning of the line where the current cursor is located
A: Enter at the end of the line at the current cursor
O: Opens a new line above the line where the current cursor is located
Input mode--edit mode
Esc
Edit Mode--last-line mode

Last-line mode--edit mode
Esc
3. How to close the file, usually in the last line mode
: Q exit
: q! Force exit
: Wq Save Exit
: X Save exit
: W/path/to/somewhere saved to the specified location
ZZ Save exit
4. How to implement cursor jump (usually in edit mode)
Between characters jump: h,j,k,l
#COMMAND: A character that jumps to a number specified by a #
Between words jump: e,b,w
#COMMAND: # Specifies the number of words to jump at a time
Beginning line end Jump: ^,0,$
Interbank movement: #G, G,gg (/g)
Move between sentences:), (
Move between paragraphs:},{
5. Turn screen operation
CTRL+F: Flip a screen to the end of the file
Ctrl+d: Turn half screen at the end of the file
CTRL+B: Flip a screen to the file header
Ctrl+u: Turn half screen to file header

Vim in edit mode of the relevant instructions
1. Character editing
X: Delete the character at the cursor
#x: Delete the # characters at the beginning of the cursor
XP: Swap the position of the character where the cursor is located and its character
2. Delete command
D: Delete command, can be combined with the cursor jump character to achieve range deletion
d$
d^
D0
Dw
Db
De
#COMMAND
DD: Delete cursor in the row
#dd: Multi-line deletion
3. Paste command
P: If the buffer is a whole row, paste the current cursor below the row, or paste it at the end of the current cursor.
P: If the buffer is a whole row, paste the top of the current cursor, or paste it in front of the current cursor where it is located
4. Copy commands
Y: Copy, work behaves similar to D command
y$
Y0
y^
Ye
yw
Yb

#COMMAND

     yy: Entire row copy
         #yy: Copy multiple lines
   5. Change command (c,change)          
      C: The edit mode will automatically enter the last line mode
        C $
       when the modification is complete   c^
        c0
        CB
        CW
        CE
           #COMMAND
      cc: Delete and enter new content
    6. Undo Command
       u (undo): Undo previous Actions
       #u: Undo a specified number of actions
     undo Previous undo
       Ctrl+r
      repeat the previous edit command
      .

Vim instructions in the last-line mode (built-in command-line interface)
1. Address delimitation:
: Start_pos,end_pos

#: The specific # line
#,#: From the left # indicates the line start, to the right # indicates the end of the line
#,+#: From the left # indicates the start of the line, plus the number of rows on the right #
. : When moving forward
$: Last line
%: Full text, equivalent to 1,$
/parttern/,/parttern/: Starting from the first line that is matched to the pattern1 pattern, until the end of the line that was first matched to the PATTERN2
#,/pattern/:
/pattern/,$:
2. Find
/pattern: Looks at the end of the file from the current cursor location
? PATTERN: Finds the file header from the current cursor location
N: Same direction as command
N: Opposite direction of command
3. Find and replace
S: Complete the Find and replace operation in the last line mode
s/what to look for/replace with content/modifiers

          What to look for: Available modes
           Replace with: cannot use mode, but can use/1,/2, Wait for the back reference symbol. You can also use "&" to refer to the entire content found in the previous lookup, so with "&" is not replaced, the satellite added the content
          Modifier     :
                   I: Ignore case
                   g: Global substitution, by default, each row replaces only the first occurrence of the pattern
           NOTE: The delimiter "/" in the find substitution can be replaced with another character, for example:
             [ email protected]@@
             s###

Related instructions for VIM multi-file mode:
Vim FILE1 FILE2 FILE3 ...
: Next Next
: Prev Before a
: First One
: Last One
: Qall Quit all
: Wall Save All

The relevant instructions for the Vim window split mode:
Vim-o|-o FILE1 FILE2 ...
-O: Horizontal split
-O: Vertical split
Switching between windows: Ctrl+w,arrow

Customizing the working characteristics of vim:
1. configuration file: Permanently valid
Global:/ETC/VIMRC
Personal: ~/.VIMRC
2. Set the operating characteristics in the last line mode, but only valid for the current VIM process
1). Line number
Display: Set number, abbreviated as set Nu
Cancel display: Set Nonumber, abbreviated to set Nonu
2). Parentheses match:
Match: Set Showmatch, abbreviated as set SM
Cancel: Set NOSM
3). Auto Indent
Enable: Set AI
Disabled: Set Noai
4). Highlight Search
Enabled: Set Hlsearch
Disabled: Set Nohlsearch
5). Syntax highlighting
Enabled: Syntax on
Disabled: Syntax off
6). Ignoring the case of characters
Enable: Set IC
Disabled: Set Noic
7). Get Help
: Help
: Help Subject


This article is from the "Fante" blog, make sure to keep this source http://8755097.blog.51cto.com/8745097/1690274

The command ' vim ' and how to use it

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.