Vim Multi-File editor "super-Practical"

Source: Internet
Author: User
Tags exit in switches

Vim Multi-file editor (even Linux notes) http://blog.csdn.net/lcj_cjfykx/article/details/18805721

Each file opened with vim corresponds to a buffer (buffer is the memory space allocated by the system to the open file), and each buffer has an ID.

1. Display multiple files under the same window

Command: Vim filename1 filename2

: N switches to the next file

: N switches to previous file

: n filename2 switch to file filename2

: LS lists information about all the files that vim opens, including the file name, buffer ID, etc.

: B2 switch to buffer with buffer ID 2

: Bn switches to the next buffer in the current buffer

: BP switches the previous buffer of the current buffer

: Bd2 closes buffer with buffer ID 2 and the corresponding file is closed

The completion of editing can be used to exit Q, you can use the QA all-in-one exit.

2. Split window, display multiple files

For the opening of multiple files in the same window, for the copy of the content between the files, the cut operation is not convenient, we can use the command to split the window, each child window display a file

Command: Vim-o filename1 filename2 Horizontal Split window

Vim-o filename1 filename2 Vertical Split window

In this way, it is very convenient to copy and cut between the contents of each file, here by the way simply mention copy, cut and paste Operations command

YY the copy cursor is in the row

DD clipping cursor is in the row

5yy Copy the next five lines of text counting from the line where the cursor is located

5DD clipping the next five lines of text counting from the line where the cursor is located

V (lowercase) Visual mode, selects all characters of the cursor "swept" by the left and right key

V (uppercase) Visual line mode, select all rows of the cursor "swept" by the upper and lower keys

Ctrl + V visual block mode, select a rectangular text by the top and bottom keys

Y copy selected text in visual mode, visual line mode, and visual block mode

D Cut text selected in Visual mode, visual line mode, and visual block mode

P (lowercase) paste, paste position is the next line of the cursor

P (uppercase) Paste, paste position is the previous row of the cursor

Tips:

A. If we open more than one file through vim, and want to continue to open other files without turning off vim, such as file, you can use the following command in VIM:

: E file does not split the window

: SP file will split the window horizontally

: VSP file will split the window vertically

B. Switching between vim and shell

: Shell switches to Shell when Vim is running in the background, enter command exit in Shell, switch back to VIM

C. Execute shell command in vim (do not switch to shell)

:!command before executing the command! , such as!ls,!ls-a

: R!command Inserts the command command's execution result into the next line of text in the current line

: 3!command The contents of the third line in the text into command commands for processing and replaces the contents of the third row with the execution result of the command

: 1,3!command The contents of the first line to the third line in the text into command commands for processing, and replaces the contents of the first row to the third row with the command's execution result

: 3 W!command the contents of the third line in the text into the command commands for processing without changing the contents of the current edited file.

: 1,3 W!command the contents of the first line to the third line in the text into command commands for processing without changing the contents of the current edit file

Vim Multi-File editor "super-Practical"

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.