Basic use of VIM in the Linux text editor

Source: Internet
Author: User
Tags linux text editor

A text editor is used to create or modify a text file. Three modes of Operation:   Command mode-->> edit mode--->> command line mode.      mode switch:     enter file       --Command mode       appears insert    --edit mode      input:          --command line mode          edit mode---"command line mode:            edit Mode--" esc key  --"   Command mode--" : Key  --- "  command line mode          character manipulation (how to enter edit mode):         i  Key: Inserts a character before the cursor.         I  key: Insertion at the beginning of the line.         a  Key: Inserts a character after the cursor.         A  key: End of line insertion.         o  key: Insert next line.         O  key: Insert the previous line.         x  key: Deletes one character backwards.         X : Deletes a character forward.         u  key: Undo One step and undo it once per press.         r  key: Replace.           line operation (Command mode):         home key or ^ (shift+6)   moves the cursor to the beginning of the current line.         end key or $ (shift+4)    moves the cursor to the end of the current line.                  Delete Row:            dd   Delete a row, the number +dd   delete multiple rows.             Delete all content after cursor d+g                  Show line number:set nu                  copy and paste:yy  copy a row, #yy    copy # line. p  pasted at the cursor positionAfter the,p  is pasted at the cursor position.                  Shear:             first Delete, then paste.             Delete to the beginning  d + home  or  ^ ( shift+6)             Delete to end of line  d + end    or  $ (shift+4)                       u   Undo One-step operation.           U   undo all edits made to the current line.           ZZ   Save the current file contents and exit the VI editor.                             positioning:         vim to a row:             operating:          in command mode          gg (or 1G)    navigate to the first line of the file.                  G     navigates to the end of the file line.                  :#    Navigate to a row (#表示行号) .                   #G    Navigate to the file # line.       v mode:           into v mode, Moving the cursor selection area,           programming requires multiple lines of comment:              *  ctrl+ v   Enter column edit mode.              *   move the cursor down or up               *   marks the beginning of the line to be annotated.              *   then press the uppercase i              *   re-insert an annotation, such as "#"               *   Press ESC again, and it's all commented out.                          Delete Annotations:                 Press ctrl+ v  to enter column edit mode;  move the cursor down or up, select the comments section, and then press D to remove the annotation symbol.                      vim  command line mode operation:          : w     Save.           : q    exit directly, do not save. (quit) .          : q!   modified, not saved, forced to quit.           : wq   Save and exit.           : wq!  force save and exit.           : x    Save exit.           : w  file path     Save as another file.                    Call external file or command:            : ! + command                   replace (command line mode):           format: %  All content   s  replace    old content   new content            default is the first qualifying word for each line   (/g  all)                      : % s/a/b  :  the first a in each row is replaced with b           : % s/a/b/g :   Replace all A in text with b.                      replaces only a few lines of content:               : 2,3  s/a/b   :  Replace 2 to 3 lines of a                                             : set nu    Displays line numbers.               : set nonu     does not display line numbers.                               Find:                  /  forward lookup   /abc    n  down lookup,  n   Look up.                  ? String   :   find string from bottom up.                       read other files:              in command line mode:                : r   File path                 save and exit    : wq                              : e    File path      open a new file for editing.                       vim  Open multiple files:          ] #vim   -o     file path    another file path          ] #vim    -O    file path    another file path                    ctrl + ww   switch between files.           Capital  O  left and right split screen,  lowercase  o  up/down split screen.                      Compare file contents:         vimdiff   file a    file b


This article is from the "Enron Smile" blog, please be sure to keep this source http://liyuanjie.blog.51cto.com/12877605/1972319

Basic use of VIM in the Linux text editor

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.