Linux Commands: Vim

Source: Internet
Author: User

I. Introduction of VIM

Installing Vim:yum install–y vim-enhanced
Vim mode: Normal mode, edit mode, command line mode

Second, VIM's shortcut keys

number 0 move to the beginning of line
shift+4         Move to end of line
shift+a         Move to end of line and enter edit mode
o               move to the next line and into edit mode
gg             move to first line of text
shift+g         move to the last line of text
n + shift+g     Move to the first few lines

YY copy entire row
N+YY Copy N rows
P Paste

x Delete/cut cursor character
DD Delete/cut entire row
N+DD Delete/cut several lines
d$ Delete/Cut the contents (one line) after the cursor location
d^ Delete/Cut the contents (one line) before the cursor position

v Select character
R replaces the current character
u undo Last Action
/Find keyword (n key to switch in the found results, enter: Noh to cancel the search)
ctrl+r anti-revocation
pgup/pgdn up/down page

: W Save
: Q Exit
: q! Force exit, do not save changes
: x Save and exit, equivalent to: Wq
: Set NU displays line number
: Set Nonu cancel line number
:! System command, executes a system command and displays the result
: SH switch to command line, use CTRL + D to switch back to VI
: 1,10s/ip/ip/g text substitution (replace 1 to 10 lines)
:%s/ip/ip/g text substitution (replace all)% for entire document, s for replace, IP for original text, IP for replaced text, G for global substitution
:%S/IP/IP text substitution (replaces only the first one that appears in each line),

Note: the deletion of characters in the general mode is not really deleted, just put it on the Clipboard, press p can also be pasted out

Extension: How to indent multiple lines at once

In the VIM command mode press CTRL + V to enter the visual block mode, then move the cursor down, select the line to indent, then press shift+i, enter insert mode, hit 4 spaces, and finally press ESC, the corresponding line is automatically indented 4 spaces.

Linux Commands: 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.