Vim text editor in Linux

Source: Internet
Author: User
Tags bulk insert file handling

Vim Text Editor

What is the 1:vim text editor?

Vim is a well-known, powerful, highly customizable text editor similar to VI, which improves and adds many features on the basis of VI.  Vim is free software. (from Baidu Encyclopedia)

2:vim Editing files

Vim file name #保存后即可建立一个文件

Four modes of 3:vim

(1) Normal mode : mainly used to browse and modify the text content, general, open Vim is normal mode. In any mode, you can return to normal mode as long as you press the ESC key.

(2) Insert mode : Insert mode is used to add content to the text

~~~~~~~~~~~~~~

GG #移到文件第一行
G #移到文件最后一行
I #vim into insert mode to insert at cursor position
I #vim INSERT into insert mode at the beginning of the cursor
A #vim Enter insert mode at the next position in the cursor position
A #vim into insert mode at the end of the line at which the cursor is inserted
o #vim into insert mode, insert the next line where the cursor is located
O #vim into insert mode on the line where the cursor is inserted
s #vim Enter insert mode to delete the character insertion of the cursor
S #vim Enter insert mode to delete the row where the cursor is inserted

~~~~~~~~~~~~~~~~

(3) Visual mode : The visual mode is equivalent to the normal mode after highlighting the selected text

~~~~~~~~~~~~~~~~

CTRL v into visual mode
Use the left and right key to select the area you want to operate and then you can perform VIM command mode

Bulk INSERT characters:
Ctrl + V Select the line I want to add the character to enter what to insert and then exit

~~~~~~~~~~~~~~~~~

(4) Command mode : It is used to manipulate the text file (instead of manipulating the contents of the text file), for example, to save the file, or to change the state of the editor itself, such as setting a multi-column window, a label, or exiting the editor

~~~~~~~
: Set Nu #加行号
: Set Nonu #取消行号
I #编辑模式
: Wq Save Exit
: q!
: Set Mouse=a #使用鼠标
: Set Cursorline #添加行线
~~~~~~~
Note: The above command is only changed in the current shell, and the permanent vim is added in the VIM/ETC/VIMRC mode of operation;

Some common file handling shortcuts for 4:vim

~~~~~~~
/Find part N to match n up match #高亮显示
U #撤销
CTRL R #撤销后的撤销
Delete:
DW #删除一个单词
d3w #删除三个单词
DL #删除一个字母
DD #删除一行
D3D #删除三行单词
Copy:
YW #复制一个单词
YL #复制一个字母
YY #复制一行
P #粘贴
Clip:
CC exit insert mode P (paste) #剪贴
~~~~~~~~~~

5:vim the problem of abnormal exit

~~~~~~~
Direct-off Vim a hidden file is generated when the system exits abnormally. FILE.SWP vim will appear when you edit this file again
~~~~~~~
o Reading
E-Edit
R restores the newly entered
D Delete
Q exit
A (check)
~~~~~~~
Workaround: Delete. file.swp
6: Bulk Operations

~~~~~~~~~~
(1) Bulk INSERT characters:
Ctrl + V Select the line I want to add the character to enter what to insert and then exit
Bulk conversion of characters:
(2) Batch Conversion

:%s (full text)/original character/converted character/g (full-text conversion) without G (convert only the first of each line)
: 1,5/original character/converted character/convert character of the line
~~~~~~~~~~

7:vim Split-screen function


Vim's split-screen function (Exit command mode)
Ctrl+w s #上下分屏
Ctrl+w v #左右分屏
Ctrl+w up or down #移动光标到制定屏幕
Note: The first wq! used when saving the split screen Save the second split screen directly in wq! The address of the appended file
: SP + other file address #一个vim下同时编辑两个文件
Save and exit of 8:vim

W: Write

Q: Exit

! : Force

Q (Do not save exit)/q! (Do not save forced exits)/wq (save exit)/wq! (Save forced exit)





Note: The above collation is the usual VIM command, and subsequent additions will continue

This article is from the "12462896" blog, please be sure to keep this source http://12472896.blog.51cto.com/12462896/1949979

Vim text editor in Linux

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.