:xis equivalent to the following command:
:wqSaves the current file and exits.
Difference: These two commands are not actually equivalent, and the two commands are the same when the file is modified.
But if it is not modified, using :x will not change the modification time of the file, and using :wq will change the modification time of the file.
Basic CalculatorIn insert mode, you can use Ctrl+r and then enter =, then enter a simple formula. Press Enter and the result will be inserted into the file. For example, try typing:
Ctrl+r '=3+6' ENTERThen the result of the calculation “9” will be inserted into the file.
Finding Duplicate Continuous WordsWhen you type quickly, it is very likely that you will enter the same word twice in succession, just like this this. This kind of mistake may fool anyone, even if you re-read it yourself. Fortunately, there is a simple regular expression that can be used to prevent this error. Use the search command (by default /) and enter:
\\(\\<\\w\\+\\>\\)\\_s*\\1This will display all duplicate words. To get the best results, don't forget to put the following command:
set hlsearchin your .vimrc file to highlight all matches.
AbbreviationsThe syntax is as follows:
:ab [abbreviation] [text to be replaced]A general example is:
:ab asap as Soon as possiblewill replace the “asap” you entered with “as soon as possible”.
Save files when you forget to open files in rootWhenever you open a file (such as a system configuration file) that you don't have write access to, and make some changes Vim cannot be saved by the normal “:w” command.
You don't need to re-open the file as root and modify it. Just run:
:w !sudo tee %This will be saved directly as root.
To ensure that the user is in
AutoCompleteNot to mention the autocompletion provided by the plugin, just say that Vim has autocomplete by default. It's true that this feature is very basic and can be enhanced with plugins, but it is also very helpful.
Vim tries to predict the end of a word from words that have already been entered. For example, when you enter “xiaogongjiang” for the second time in the same file, just enter “x” or more, then keep in insert mode, press Ctrl+n to see Vim fill in the words for you. . It's simple, but it's also very useful.
Comparing the differences between two filesThe vimdiff command, which can open Vim in split mode and compare the differences between the two files. The syntax is as follows:
$ vimdiff [file1][file2]But the same result can be obtained with the following Vim command:
:diffthisFirst at Vim Open the original file. Then use the split mode to bring the second file:
:vsp [file2]Finally type in the first buffer:
:diffthisby Ctrl+ w to switch the buffer and type again:
:diffthisThe different parts of the two files will be highlighted.
You can use the command directly in a buffer: windo diffthis instead of typing: diffthis twice)
Backing up files by timeVim will record changes to the file, you are very It's easy to fall back to a certain time ago. This command is quite intuitive. For example:
:earlier 1mwill roll the file back to the state 1 minute ago.
Note that you can use the following command to do the opposite conversion:
:later delete the text inside the tagWhen I started using Vim, I always What you want to do very easily is how to easily remove the contents of square brackets or parentheses.
Go to the start tag in normal mode,
Then use the following syntax:
di[tag]For example, put the cursor at the beginning of the parenthesis On, use the following command to remove the text inside the parentheses:
di(If it is a square bracket or a quotation mark, use:
di{and :< Br>
di"
Deleting the content before the specified tagThere are some similarities inside the delete tag, but the purpose is different. The command is as follows:
dt[tag]will delete all the content between the cursor and the mark (keep the mark does not move), if there is this mark on the same line. For example,
dt.will be deleted to the end of the sentence, but keep &lsquo ;.’ does not move.
Convert Vim to hex editorYou can connect Vim and xxd functions to convert files to hex mode. The command is as follows: Br>
:%!xxdSimilarly, you can restore the original state by the following command:
:%!xxd -r Skip to the previous/next positionThings you often do when editing a large file Modify it somewhere, then jump to another place. If you want to jump back to where you modified it, use the command:
Ctrl+oto go back to where you previously modified
Similar:
Ctrl+iwill roll back the above.
Convert the current file to a web pageThis will generate an HTML file to display the text and Separate window display source code:
:%TOhtml
After reinstalling Win7, I have never tried to install Linux again, occasionally playing, an
Preparation before installation 1. kail linux 2.0 download (multiple versions of ISO) Downl
Today, Xiaobian is a beginner Linux developer to explain how to install Linux. Here Xiaobian
Through the network port bonding (bond) technology, network port redundancy and load balancing can b
The semaphore implementation of the Linux kernel source code
Exit command--Linux command application big dictionary 729 command interpretation
Gcc parameters commonly used under Linux
Vi editor paste copy cut function under Linux
Set up regular execution scripts under Linux
How to restart the most secure after Linux crashes
Linux hard disk partition format and mount
Ubuntu13.04 sets static ip (whether notebook, desktop, virtual machine)
Microsoft created a background process: twice a day to detect Windows 7/8.1 update update
Turning off XP's Top Ten Hazards Improving System Security
Windows Desktop In-Tester Tests Windows 10 Store with New Interface
Repair session snapshot Notepad++ 6.6.2 Chinese version release
How to set the power-related options for the win10 system?
Jinshan WPS mobile phone remote PPT playback method
Detailed explanation of the functions of the windows directory folder
Teach you 20 special tips for Winxp
What if the Win7 language bar is missing? Win7 system to retrieve the language bar method
Win10 multi-screen split screen set the operation method of different backgrounds