Vim Common commands

Source: Internet
Author: User
Tags save file how to use git

Set auto indent: Set autoindent
Set indentation Level: Set Shiftwidth=n (n=1,2,3 ...) Indent several spaces.
Turn off Auto indent: Set noautoindent

1. How to edit

Pressing the ESC key at any time will enter normal mode. In normal mode you can press: to enter the command.

Normal mode Press I or a to enter insert mode, at which point you can edit the text.

2. Simple editing
    • Move cursor: You can use the arrow keys to move the cursor, more vim is the practice of HJKL
    • Save file in Normal mode: W. Exit Edit: Q, forcibly Save: w! Forced exit:: q!
    • Undo operation: U or Normal mode press U
3. Faster editing

Now you can write something with vim.

We need faster editing.

1. Quick Position cursor:

    • ^ Jump to the beginning of the line (similar function key home)
    • $ jump to end of line (similar function key end)
    • : N Jumps to nth row
    • : $ jumps to the last line

2. Quick edit:
In normal mode:

    • DD Delete a row
    • YY Copy a row
    • P Paste
    • R Single character substitution

3. More Granular paste copy:

    • M,nd-Quick Delete m to nth row (delete)
    • M,ny-Copy M to Nth line (Yank)
    • M,NMT-line m to nth line cut to line T (move)
    • M,ncot-line m to nth row copied to line T (copy to)

4. Search
Press/down search in normal mode, press to search up
5. Align
Gg=g quickly aligns the entire file
6. Label operation

    • : Tabnew Mytab Create a new label Mytab
    • : Tabn jumps to the next tab
    • : TABP Jumps to previous tab
    • Jump to the next and previous tab in normal mode with GT or GT

7. Cutting window operation

    • : Split horizontally to cut a window
    • : Vsplit a window in vertical direction
    • Use the ctrl-w+ arrow keys to switch between each cutting window.
4. Let vim know you better

Have you noticed that we have not mentioned VIMRC and plugins.

Now it's time to go.

For example, when we coding, we like to show line numbers: Command mode: Set NU or: Set number

About VIMRC, there are a lot of places worthy of discussion, you can refer to my VIMRC, I have made detailed Chinese comments

5. About Plugins and themes

Vim color has three more famous, solarized, Molokai, Badwolf

For Vim's plugin, there are only a few words to say:

      • Be sure to use Vundel to manage plugins.
      • Do not modify other people's plugins, either you fork the changes yourself, and then bundle your plugin.
      • You can study how to use git submodule to manage your plugins.

Vim Common commands

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.