I would appreciate it if someone can let a newbie know what the differences are between vi
and vim
. I've heard Vim is a successor to vi
but whenever I try to open vi
in Ubuntu it opens vim
instead.
I would appreciate it if someone can let a newbie know what the differences are between vi
and vim
. I've heard Vim is a successor to vi
but whenever I try to open vi
in Ubuntu it opens vim
instead.
Functionally, vim is almost a proper superset of vi. Therefore, everything that is in vi is available in vim.
Vim adds onto those features. Here are a some of the extended vim features:
There are many more differences. Refer below sources which are few of good places to start finding out more.
Source: Vim.Org, Vim on Wikpedia.
Hope it helps! :)
"vi" is a text editor from the early days of Unix. It became quite popular and made its way into the Single Unix Specification (SUS) and POSIX, but wasn't freely available until 2002.
So, several free vi-like editors emerged. Vim ("vi improved") is one of these editors. As the name suggest it adds lots of functions to the original vi interface.
In Ubuntu Vim is the only vi-like editor installed by default, and
vi
actually starts Vim by default.Other popular vi-like editors available in Ubuntu are, for example,
nvi
andelvis
.vi editor is the most popular text editor in Linux. We can say it has a simple black and white screen i.e. if you type any command there is no code highlighting, where as vim is improved version of VI it also has features same like vi but it also has code highlighting.
Both have these 4 basic modes:
The Vim FAQ has a well formatted list: https://vimhelp.org/vim_faq.txt.html#faq-1.4
Excerpt from the FAQ:
There is indeed quite a big difference between them. I use both nvi and vim daily. Neither of them are perfect, but they're still better than anything else is out there.
Vim has more of everything. In addition to syntax hilighting (when compiled with a support for it) it does automatic conversions of charactersets, line-endings and such. It has multiple ways of numbering lines, which is really convenient. Vim certainly has a lot that speaks for it.
Unfortunately vim breaks the vi philosophy by mixing the editor modes and introducing a vast number of useless and redundant functions. Sure it's convenient at first that you can for example move with cursor keys in insert mode, but it also has some really weird unwanted side-effects (for example the . gets quirky and unpredictable).
Vim (while certainly being IMproved as it claims) is also a bloated, weird and inconsistent mixture of a broken vi and a modeless editor. :P
I still love it, though. And you can fix most of that by tuning you configuration ;D
To add to what @gen said, it is easier to read it straight from vimhelp.org, if you don't wish to test things yourself. The reality is most people use very little of "real" vi's capabilities and even less of vim's or nvi's.
https://vimhelp.org/vi_diff.txt.html
https://vimhelp.org/options.txt.html#%27compatible%27
https://vimhelp.org/vi_diff.txt.html#posix-compliance
The biggest thing I notice is how undo / re-do has been brok.. er.. "improved" in vim, the non-classic behavior of the "BACKSPACE" key, and how slow vim-tiny is compared to n/vi at times. One append of 50,000 repetitions can lock a session up for almost an hour in any vim version I've ever tested. A 2,000,000 append of the same data in nvi takes less than 5 seconds. The vim Devs know about this bug but do not think it is worth fixing.
^[50000aUse vim or nvi or vi?^[
Better not try that in vim on a Production box. Just sayin'
If you don't know, ^[ is the code for the "ESCAPE" key. You SHOULD know that.
Generally your basic vim skills of ^[ibla foo bar^[:wq! will transfer enough to "real" vi if you need to support a real UNIX such as AIX, HP-UX, or Solaris. But if you rely on arrow keys to "move around" while in Insert mode then you are going to be in for a rough time. You should not be moving the cursor around in Insert mode, arrrow keys or otherwise, 1980's or not. Movement is meant to be done in Command mode. It is faster and allows you to use the actual power of vim|n/vi. Otherwise you might as well be using MS Win Notepad. If you use vim|n/vi as intended then the hjkl and/or arrow keys --in Command mode-- will still be your last resort for getting around in a file. It is too inefficient and slow. You type "new" text in Insert mode, while almost all movement and text editing is done in Command mode.
This is the part many people don't seem to get. Arrow keys don't work in Insert mode and type "garbage" when they are pressed because they are literally telling vi to "insert" the control code for your arrow key, so it does: ^B. Then people complain that UNIX/vi is doing what they told it to do! If you don't want vi to Insert the character then stop telling it to. Simple: Movement is done in Command mode.
Also, vim|n/vi have 2 modes in common: Insert mode and Command mode. There is no such thing as "Escape" mode. ^[ just puts you in Command mode.
n/vi does not have a "Visual Block" mode, which is specific to vim. But since marks have served that purpose in vi since the late 1970's then I question why a Visual Block mode is necessary. Maybe for people who actually use the COLUMN selection feature?
Not knowing what vi marks and named buffers are, or how to use them demonstrates that people have not went through some of the most basic vi tutorials that have been around since the 80's or even read the man pages.
Finally, to all the people who think "vi" is on Ubuntu, or almost any GNU/Linux system, for that matter -
:version
The name is almost certainly a symlink to some vim binary somewhere.
All of this information has been publicly available about vi for around 40 years now.
-EDIT- I just thought of 2 other ways that vim is not POSIX vi:
Vim is also a Linux text editor. It is an upgraded version of vi, and its full name is vi improved. In addition to the functions of vi, it has the features of multi-level undo, visual operation, syntax highlighting, and ease of use. Both vi and vim are editors in Linux. The difference is that vim is advanced and can be regarded as an upgrade version of vi. vi is used for text editing, but vim is more suitable for coding. Linux ESC: The difference between vi and vim