1, before the operation of the actual line with G, you can operate on the screen line, for example: ' GJ ' means to move down a screen line, ' g^ ' for moving to the screen line of the first non-whitespace characters and so on2. Vim has two sets of commands for forward and reverse movement of words:
W forward moves to the beginning of the next word
b Reverse moves to the beginning of the current word/previous Word
E forward moves to the en
Vim Find replacement: n1,n2s/word1/word2/g N1,n2 is a number, find N1 to N2 line, word1 Replace with Word2: 1, $s/word1/word2/g find the first line to the last row, word1 replace Word2: 1, $s/word1/word2/gc find the first line to the last row, word1 replace Word2 before replacing the confirmation.Configuration of the VIM environmentSet NU Display line numberSet Nonu suppress line number displaySet backspace
A book worth reading, "Vim practical Tips"I contacted Linux in 2014, in the process of using the Linux Vim editor, encountered some vim editor skills, feel good magic, strong. Linux Basic Books also introduce Vim, but not comprehensive, so at the end of 2015, decided to find
Summarize some of the practical functions that we use the vim editor at ordinary times, which will be updated in the future.1. visual plug-in
The visual plug-in is actually equivalent to a bookmarks. For example, in a long source code file, we can mark a line, and then we want to return to this line, you only need a shortcut key to quickly locate this line, which is very convenient and does not need to go u
Vim/VI Practical Skills
1. Import files
: R [file name] # import to the currently edited File
For example, R/etc/inittab
The upper part of the file is the/etc/services file, and the lower part is the/etc/inittab file.
2. Run the command [do not exit VI]
:! [Command]
:! Ls-L/home/hadoop
Extended-import the command execution result to the currently edited file!
: R! Date
3. Define shortcuts
: Map [shor
Note the following before reading this article:
1. The goal of this article is to provide some vim usage skills, which can improve the efficiency of vim operations. Some tips can also be used on vi, but now vim is basically used.
2. this article describes how to sort out and summarize the usage skills, rather than explaining how to get started with
First, Getting Started
Portal: "Concise Vim training Strategy"
Second, good things (personal ranking)
ViwSelect the word at the cursor (in front of the light)
No.2
GdAt the definition of the property or method where the cursor is located
No.3
YiwCopy the word at the cursor (similar to the very same)
No.3
andSearch backwards and forwards for the keyword that the cursor is in
No.4
C+n (i.e. CTRL + N)Complement fun
Sometimes we modify some code, and the tab setting in this code is not the same as our own setting. For example, our own setting is to replace tab with two spaces, while the code to be modified uses tab. So, how do we quickly convert the tab to a space?Refer to Http://vim.wikia.com/wiki/Converting_tabs_to_spaces, the method is as followsFirst, set the tab configuration correctly, for example1 : Set tabstop=22 : Set shiftwidth=23 : Set ExpandtabNext, you can enter the following command.1 : RetabS
1. Insert text
I, of course, is commonly used. But if I is used only, it is too TB. Remember I, O, and,Of course, it is case sensitive. It generally distinguishes the concepts before and after. This is the principle that Vim is designing various commands.
Operation memory for Command Execution ----------------------------------------------------------------- I insert characters on the left of the cursor I insert characters at the beginning of a
When Vim is used in the terminal for editing, by default, no line number, high syntax brightness, and smart indentation are displayed on the editing interface.
. To better work in Vim, You need to manually set a configuration file:. vimrc.When Vim is started, the. vimrc file under the root directory of the current user will be automatically read. This file can
1.vim has not started yet:Enter in terminalvim file1 file2 ... filen can open all the files you want to open2.vim has startedinput: Open Filea file can be opened again, and the contents of the file will be displayed in Vim at this time. display multiple files at the same time:: Split: Vsplitto switch between files:1. Inter-file switchingctrl+6-Next File: bn-Next
1. In edit mode: Ctrl+w undo the last edited content2. In command mode: CTRL+W cursor switch to another window3.vim-on file1 file2 ... The horizontal split screen, n is the number, represents divided into several screens, the command input succeeds, divides into the top and bottom multipleScreen.4.CTRL+W+J cursor moves to the bottom of the screen, ctrl+w+k the cursor to the top of the screenCtrl+w+h left cursor ctrl+w+l right move cursor5.
Chapter 1
First, we put forward the idea of VIM: how to improve reuse -- easily repeat previous operations.In addition, the author divides Vim operations into two steps:
One is mobile, and the other is operation.
For these two aspects, the reuse is achieved through commands: ";", "," n "," n ",". ", and" U.
Modify operationCommand mode DD and so on are all modification operations, but it is easy
under Windowshkey_classes_root\applications\gvim.exe\shell\edit\command its key valuemodified to: "D:\VIM\vim74\gvim.exe"-P--remote-tab-silent "%1"among them, "D:\VIM\vim74" is my path to install VIM, note according to the actual modification. and if you use the right mouse button "edit with Vim", first delete the reg
)
Select, copy, or find the word where the cursor is locatedIn vim, use IW or AW to represent a word, which is slightly different, and a indicates the spaces that are included before the word:Select the word where the cursor is located: Viw (v enters visual mode, then IW)The word where the cursor is copied: Y (a) W () indicates orDelete the word that is located in the cursor: D (a) WFind the word where the cursor is located: * Look down, #往上
Efficient mobile
Outside of the insert mode
Basically, you should stay in the insert mode as little as possible, because Vim is like a "dumb" editor in the insert mode. Many beginners will stay in the insert mode because it is easy to use. But the strength of vim is in his command line mode! You'll find that after you get to know vim more and more, you'll spend
the line
A inserts the contents after the current cursor
I insert content before the current cursor
Compound Command equivalent long command function
C $ Delete all the current cursor to the end of the line and enter insert mode
s cl deletes the current cursor content and enters insert mode
S ^c Delete the current entire line and enter insert mode
I (Capital letter i) ^i moves to the beginning of the line and inserts the contents before the curre
http://blog.csdn.net/pipisorry/article/details/395084171. Replace VI with VIMVim is more powerful than VI, Vim is a superset of VI, and can solve many of the problems of habit, so it is necessary to use Vim to replace VI. Simply speaking, you can directly use the "Alias Vi=vim" command, but this can only be useful in this launch, the next time after the start, t
:
Exit command is, press ESC to jump to command mode, and then enter: Q (not saved) or: Wq (save) exit. more exit Commands:
: w save file but not exit VI: W file will be modified to save in file, do not exit VI: w! Mandatory save, do not launch VI: Wq save file and Exit VI: wq! Force file to save and Exit VI: Q Do not save files, exit VI: q! Do not save file, Force exit VI: e! Discard all modifications and edit command history from the last save file
Commands with: and/start with history, you ca
Vim note (6) -- a more comprehensive introduction of vim (for example, vim -- vim)
Vim configuration file~ /. Vimrc user's default configuration file ~ /. Vim/plugin/user's default script file storage directory ~ /.
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.