A practical way to use vim

Source: Internet
Author: User

    1. Vim tab Turn four spaces
      Vim/etc/vim/vimrc
      Set et sta sw=4 sts=4

    2. For a saved file, you can use the following method to replace the Space and tab:
      tab is replaced with a space:
      : Set ts=4
      : Set Expandtab
      :%retab!
      Space is replaced with tab:
      : Set ts=4
      : Set Noexpandtab
      :%retab!
      Add! is the tab that is used to process non-whitespace characters, that is, all tabs, if not added, only the tab at the beginning of the line is processed

    3. To open multiple files:
      Ctrl+p lists multiple files and automatically complements them in a way that
      Ctrl+6 switching between two files
      , b top dropdown list file-next page, prev, CTRL + N, ctrl+p

    4. How to switch between panes
      To open multiple windows:
      : SP//Split Horizontal window
      : Vsplit//Vertical Slicing window
      ctrl+w+ arrow key--Switch to front/bottom/up/back one pane
      ctrl+w+h/j/k/l--Ibid.
      ctrl+ww--switch back to the next pane in turn

    5. Screen cursor Position
      Top of Shift+h
      Shift+m Middle
      Shift+l Bottom

5. Search and locate:
Shift+f before the search
FF Post-Search
GD find the variable and the definition of the method where the cursor is located (local variable)

    1. Select, copy, or find the word where the cursor is located
      In vim, use IW or AW to represent a word, which is slightly different, and a indicates the spaces that are included before the word:
      Select the word where the cursor is located: Viw (v enters visual mode, then IW)
      The word where the cursor is copied: Y (a) W () indicates or
      Delete the word that is located in the cursor: D (a) W
      Find the word where the cursor is located: * Look down, #往上查找

    2. Word movement:
      W W move to the beginning of the next word
      E e moves to the end of the next word
      b b backwards to the beginning of the previous word
      It is important to note that E ignores punctuation, such as: I ' m,e will be two words, E won't
      Similarly, precede the command with a number that represents the number of executions, such as: 2w, to move 2 words down
      ?
      shift+= move to the beginning of the next line
      Note differs from above-moves to the beginning of the previous line

    3. Page
      Ctrl+u,d up and down half a page
      Ctrl+f,b up and down one page

    4. Code Folding
      Write a function, select it in Visual mode, and then ZF creates the folder. This will allow you to collapse the display. You can also create a second-level collapse.
      ZR, open all first-level folds.
      ZM, close all folds.
      ZC, close the current fold.
      Zo, opening the current fold

    5. Other:
      CTRL + V column mode
      V-line Mode
      CTRL + N code hint completion function
      The key to merge two rows with two lines is J

A practical way to use vim

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.