01-linux System Vim Editor

Source: Internet
Author: User

Vim Basic Introduction

The VI command is the most versatile full-screen plain text editor in Unix operating systems and UNIX-like operating systems. The VI editor in Linux is called Vim, which is the enhanced version of VI (VI improved), fully compatible with the VI editor, and implements a number of enhancements.

VIM Inner Finger Command

Ctrl+u: Half screen to the top of the file,
Ctrl+d: Half screen to the end of the file,
Ctrl+f: Flip a screen to the end of the file,
Ctrl+b: Turn one screen at the top of the file,
ESC: switch from edit mode to command mode;
ZZ: Save the changes made in the current file in command mode and exit VI;
: line number: The cursor jumps to the beginning of the specified line;
: $: The cursor jumps to the beginning of the last line;
X or x: Deletes a character, x deletes the cursor, and x deletes the cursor;
D: Delete all characters from the current cursor to the end of the line at which the cursor is located;
DD: Deletes the line of the cursor;
NDD: Deletes the current row and its n-1 rows;
Nyy: Saves the contents of the current row and its next n rows to the register? In, where? is a letter, n is a number;
P: Paste the text action to paste the contents of the buffer below the current cursor position;
P: Paste the text action to paste the contents of the buffer above the current cursor position;
/String: Text lookup operation, Used to find the contents of the specified string from the current cursor position to the end of the file, the found string is highlighted;
? Name: A text lookup operation to find the contents of the specified string from the current cursor position to the head of the file, the found string is highlighted, and
a,bs/f/t: Replaces the text action, which is used to change the F string to a T string between lines A and B. where "s/" means the substitution operation;
A: Add text after the current character;
A: Add text at the end of the line,
I: Insert text in the current word,
I: Insert text at the beginning of the page,
O: Insert a blank line after the current row;
O: Insert a blank line in front of the current line;
: Wq: In command mode, perform a save operation;
: w: in command mode, perform a disk operation;
: w! : In command mode, perform a forced disk operation;
: Q: In command mode, perform the exit VI operation;
: q! : In command mode, perform a forced exit VI operation;
: E File name: In command mode, open and edit the file with the specified name;
: N: In command mode, if you open multiple files at the same time, continue editing the next file;
: F: In command mode, to display the current file name, The line number of the line where the cursor is located, and the scale of the display;
: Set Number: In command mode, to display line numbers at the leftmost end;
: Set nonumber: In command mode, to not display line numbers on the leftmost side;

Command-line mode
//命令光标跳转G   跳转光标至末端gg  跳转光标至顶端Ngg 跳转光标至当前文件内的22行$   将当前光标跳转至光标所在行的末端(尾部)^   将当前光标跳转至光标所在行的头部  —> 数字0 可实现类似效果//文件内容较多ctrl+f  往下翻页(行比较多)  ctrl+b  往上翻页//复制    yy复制当前光标所在的行5yy复制当前光标以及光标向下4行//粘贴  p(小写) 粘贴至当前光标下一行   P(大写) 粘贴至当前光标上一行//删除   dd  删除当前光标所在的行   4dd 删除当前光标所在的行以及往下的3行dG  删除当前光标以后的所有行D   删除当前光标及光标以后的内容  x   删除当前光标标记往后的字符X   删除当前光标标记往前的字符//剪贴先删除dd(number dd),后粘贴p//撤销u   撤销上一次的操作(类似windows下的ctrl+z)//替换    r   替换当前光标标记的单个字符R   进入REPLACE模式, 连续替换,ESC结束
Vim edit mode
i   编辑模式(不做任何操作)I   光标跳转至本行的头部a   光标的后一位编辑A   将光标移动到本行的尾部o   在当前光标所在的行下添加空白的行O   在当前光标位置的上一行添加空白行
Vim end-of-line mode

The last-line mode is used primarily for searching, saving, and exiting files, as well as allowing users to execute external Linux commands or jump to a specific number of lines in a written document

Last-line mode (must be returned to command-line mode)
:w      保存当前状态:w!     强制保存当前状态:q      退出当前文档(文档必须保存才能退出):q!     强制退出文档不会修改当前内容:wq     先保存,在退出:wq!    强制保存并退出:x      先保存,在退出ZZ      保存退出, shfit+zz:number 跳转至对应的行号
Last-line mode (find and replace)
查找  /string 需要搜索的内容(查找)        n 按搜索到的内容依次往下进行查找        N 按搜索到的内容依次往上进行查找替换    :1,5s#sbin#test#g   替换1-5行中包含sbin的内容为test    :%s#sbin#test#g 替换整个文本文件中包含sbin的替换为test    :%s#sbin#test#gc  替换内容时时提示是否需要替换另存:w /root/test  将文件所有内容另存为/root/test读入:r  /etc/hosts  读入/etc/hosts文件至当前光标下面:5r /etc/hosts  指定/etc/hosts文件当前文件的哪行下面

01-linux System Vim 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.