In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the relevant knowledge of "what is the difference between vi and vim in linux". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Differences: 1, vi u can only undo the last command, and vim can undo unlimited commands; 2, vi can only run in unix, and vim can run in a variety of operating platforms; 3, vim syntax highlighting function, not in vi; 4, vi supports 3 modes, while vim supports 4 modes, etc.
The operating environment of this tutorial: CentOS 6 system, Dell G3 computer.
The difference between VI and VIM
They are all multi-mode editors, except that vim is an upgraded version of vi, which is not only compatible with all the instructions of vi, but also has some new features in it.
These advantages of vim are mainly reflected in the following aspects:
1. Multi-level undo
We know that in vi, pressing u can only undo the last command, while in vim you can undo it indefinitely.
2. Ease of use
Vi can only run in unix, while vim can not only run on unix,windows, mac and other multi-operating platforms.
3. Highlight the grammar
Vim can highlight your code in different colors.
4. Visual operation
That is to say, vim can run not only on terminals, but also on x window, mac os, and windows.
5. Full compatibility with vi
In some cases, you can use vim as a vi.
Both vi and vim are editors in Linux, except that vim is more advanced and can be seen as an upgraded version of vi. Vi is suitable for text editing, but vim is more suitable for coding.
VI mode
Vi has three modes: command line mode (command mode/ general mode), text input mode (input mode/ editing mode), and last line mode (last line mode/ command line command mode).
Command line mode (command mode/ general mode)
At any time, no matter what mode the user is in, just press the "ESC" key to make Vi enter the command line mode; we enter the Vi command to start in the shell environment (prompt is $), and when we enter the editor, we are also in this mode.
In this mode, users can enter a variety of legitimate Vi commands to manage their own documents. At this time, any character entered from the keyboard is interpreted as an editing command. If the character entered is a legitimate Vi command, Vi completes the corresponding action after accepting the user's command. Note, however, that the commands entered are not displayed on the screen. If the character entered is not a legitimate command of Vi, Vi will ring the alarm.
Text input mode (input mode/ editing mode)
Enter the insert command I (insert), additional command a (append), open command o (open), modify command c (change), replace command r or replace command s in command mode to enter text input mode. In this mode, any characters entered by the user are saved by Vi as the contents of the file and displayed on the screen. During text entry, if you want to return to command mode, press the "ESC" key.
Last line mode (last line mode/ instruction line command mode)
The last line mode is also known as the ex escape mode.
The functions of the Vi and Ex editors are the same, with the main difference being the user interface. In Vi, a command is usually a single key, such as I, a, o, and so on; in Ex, a command is a text line that ends with pressing enter. Vi has a special "escape" command that accesses many line-oriented Ex commands.
In command mode, the user presses the ":" key to enter the last line mode, where Vi displays a ":" on the last line of the display window (usually the last line of the screen) as a prompt for the last line mode, waiting for the user to enter a command. Most file management commands are executed in this mode (such as writing the contents of the edit buffer to a file). After the last-line command is executed, Vi automatically returns to command mode.
VIM mode
Vim has a total of four modes:
Normal Mode (Normal-mode)
Insert mode (Insert-mode)
Command mode (Command-mode)
Visual mode (Visual-mode)
Normal mode
Defaults to normal mode when vim is started. No matter what mode you are in, pressing the key (sometimes twice) will enter normal mode.
Insert mode
Press I, I, a, An and other keys in normal mode to enter insert mode.
Now just remember that pressing the I key will insert the mode. In insert mode, the corresponding characters are written when you click.
Command mode
In normal mode, press the: (English colon) key to enter command mode.
In command mode, you can execute some input and execute some instructions provided by vim or plug-ins, just as in shell. These instructions include setting up the environment, file operations, calling a function, and so on.
The commonly used commands are: Q (exit), Q! (force exit), w (save), wq (save and exit).
Visual mode
Press v, V, + v in normal mode to enter visual mode.
The operation in visual mode is a bit like operating with a mouse, and it is sometimes convenient to have a visual sense of mouse selection when selecting text.
This is the end of the content of "what is the difference between vi and vim in linux". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.