Vim Practical Small Command

Source: Internet
Author: User
vim Practical Small Command 1. How to paste command line modeThere are two modes of general VIM: Command line mode and edit mode
When we press the ESC key and then enter: After that, we enter the command mode, and then we can enter the command.
But sometimes we want to take a word from edit mode directly under the command mode for convenience, such as searching. Because it is two different modes, yy/p is not available.
In order to use copy-pasting (yy/p), we have to have the command complete under edit mode.
To this end, it is necessary Press the ESC key, and then in the Enter Q:
This allows us to enter the edit mode of the command input, which is available for all VIM commands in this command editor. After you have entered the command, press the Esc+enter key, and you can execute the command.
2. Open multiple files at the same time
Vim command can open multiple files at the same time, vim a.cpp b.cpp c.cpp Open the file, we see only one file. (1) Switch between files, command: : N or: N(2) Close all files, command: : Qall(3) Save a separate file, command: : w(4) Save all the files, command: : Wall(4) Save all the files and exit, command: : Wqall
3. Open multiple windows at the same time
The VIM command can be split on one window to display multiple files, using the command vim-o or the-o a.cpp b.cpp c.cpp for Multiple-window command operations: (1) split a window horizontally into two, the contents of the new window are the same as the old window, command: : Split(2) Split a window vertically into two, the content of the new window is the same as the old window, command: : Vsplit(3) Create a new window above the current window, command: : New(4) Create a new window on the left side of the current window, command: : Vnew(5) switch windows, press CTRL+W after pressing the direction key or Ctrl+w and then press h/l/k/j (up and Down) (6) Increase the window size, ctrl+w+ row number + "+" (7) Reduce the window size, ctrl+w+ line number + "-"
Quick Search * In the file to search forward the current cursor is the word
# Search backwards in file for the current cursor's word
Very fast Search command
When normal mode is performed, these settings commands modify only the settings of the current session, and exit or restart Vi/vim These settings are lost. To hold these settings, you must write these settings to the Vi/vim VIMRC file. For the Linux/unix operating system, each user's VIMRC file is located in the user's home directory, and the file name is. vimrc. Vi/vim reads the VIMRC file in the user's home directory each time it is started and sets the Vi/vim usage environment accordingly. Vi/vim installation also installs an example of VIMRC files Vimrc_example.vim to the/usr/share/vim/vim<version> directory. You can copy this sample file to the home directory of the current user as needed and rename it to. VIMRC, which makes it relatively easy to make changes on this basis. Other related settings about Vi/vim and key mapping are basically written to the user's VIMRC file, please refer to the Vi/vim Manual for more detailed introduction. Users can also maintain a VIMRC file of their own, and copy the file to their own use of the environment, to maintain the vi/vim characteristics in different environments consistent with their use of the habit.

another better article: https://www.ibm.com/developerworks/cn/linux/l-cn-tip-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.