Vim Tutor Summary

Source: Internet
Author: User

VIM Tutor makes you know enough commands-easily use VIM. If you wanna get full version of VIM Tutor, execute vimtutor in the shell. Lesson 1

    1. The cursor is moved using either the arrow keys or the HJKL keys:h (left), J (off), K (UP), L (right)
    2. To start Vim from the shell prompt Type:vim FILENAME
    3. To exit Vim
      • Type:: q! To trash all changes.
      • Type:: Wq to save the changes.
    4. To delete the character at the cursor type:x
    5. To insert or append text type:
      • I type inserted text insert before the cursor
      • A type appended text append after the line
Lesson 2
  1. To delete from the cursor up to the next word type:dw
  2. To delete from the cursor to the end of a line type:d$
  3. To delete a whole line type:dd
  4. To repeat a motion prepend it with a number:2w
  5. The format for a change command is:operator [number] Motion (d2w). where
      • Operator-is, such as D for delete
      • [Number]-is a optional count to repeat the motion
      • Motion-moves over the text to operate in, such as w (word), $ (to the end of line), etc.
  6. To move to the start of the line use a zero:0
  7. To move to the end of the line use a zero: $
  8. Undo
      1. To undo previous actions, type:u (lowercase u)
      2. To undo all the changes in a line, type:u (capital U)
      3. To undo the undo ' s, type:ctrl-r
Lesson 3
    1. To put the back text, which has just been deleted, type P. This puts the deleted text after the cursor (if a line is deleted it'll go on the line below the cursor).
      • Move a line to another place:dd then P
      • Move lines to Another place: (num) DD then P
    2. To replace the character under the cursor, type R and so the character you want to has there.
    3. The change operator allows a from the cursor to where the motion takes you. eg. Type CE to change from the cursor to the end of the word, C $ to change to the end of a line.
    4. The format for Change is:c [number] Motion
Lesson 4
  1. CTRL-G displays your location in the file and the file status.
      • G moves to the end of the file.
      • Number G/GG moves to this line number.
      • GG moves to the first line.
  2. Search
      1. Typing/followed by a phrase searches FORWARD for the phrase.
      2. Typing? followed by a phrase searches backward for the phrase.
      3. After a search for type N to find the next occurrence in the same direction, or N to search in the opposite direction.
      4. Ctrl-o takes you older positions, ctrl-i to newer positions.
  3. Typing% while the cursor was on a (,), [,],{, or} goes to its match.
  4. Substitute
      1. To substitute new for the first old in a line type:s/old/new
      2. To substitute new for all ' old ' on a line type:s/old/new/g
      3. To substitute phrases between-line # ' s type: #, #s/old/new/g
      4. To substitute all occurrences in the file type:%s/old/new/g
      5. To ask for confirmation each time add ' C ':%S/OLD/NEW/GC
Lesson 5
    1. :!command executes an external command. Some useful examples is:
      1. :!ls-shows a directory listing.
      2. :!rm filename-removes file FILENAME.
    2. : w FileName writes the current Vim file to disk with name FILENAME.
    3. V motion:w filename Saves the visually selected lines in file FILENAME.
    4. To delete blank spaces in multiple lines, ctrl-v.
    5. : R FILENAME Retrieves disk file FILENAME and puts it below the cursor position.
    6. : R!dir reads the output of the dir command and puts it below the cursor position.
Lesson 6
  1. Type o to open a line BELOW the cursor and start Insert mode; Type O to open a line ABOVE the cursor.
  2. Type A To insert text after the cursor; Type A to insert text after the end of the line.
  3. The e command moves to the end of a word.
  4. The Y operator Yanks (copies) text, p puts (pastes) it.
  5. Typing a capital R enters Replace mode until is pressed.
  6. Typing ": Set XXX" sets the option "XXX". Some options are:
      1. ' IC ' ' ignorecase ' ignore upper/lower case when searching
      2. ' Is ' ' incsearch ' show partial matches for a search phrase
      3. ' HLS ' hlsearch ' highlight all matching phrases
      4. You can either use the long or the short option name.
  7. Prepend "No" to switch an option off:: Set Noic
Lesson 7
    1. Type:help or press or to open a Help window.
    2. Type:help cmd to find help on CMD.
    3. Type ctrl-w ctrl-w to another window
    4. Type:q to close the Help window
    5. Create a VIMRC startup script to keep your preferred settings.
    6. When typing A:command, press ctrl-d to see possible completions. Press to use one completion.

Vim Tutor Summary

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.