# What's so great about the vi editor?

**URL:** <https://boards.straightdope.com/t/whats-so-great-about-the-vi-editor/606063>\
**Category:** In My Humble Opinion\
**Created:** [December 13, 2011, 7:33pm UTC](https://boards.straightdope.com/t/whats-so-great-about-the-vi-editor/606063 "2011-12-13T19:33:23Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![DrCube](https://avatars.discourse-cdn.com/v4/letter/d/a3d4f5/32.png) [@DrCube](https://boards.straightdope.com/u/DrCube)\
**Post date:** [December 14, 2011, 2:10am UTC](https://boards.straightdope.com/t/whats-so-great-about-the-vi-editor/606063/41 "2011-12-14T02:10:20Z")

</div>

> [@gazpacho](#):
>
> Does anybody really use vi anymore instead of vim? All the machines I have encountered in the last 5 years alias vi to vim.

My Android phone runs plain vi in the terminal.

---

<div class="post-metadata">

**Author:** ![Senegoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/senegoid/32/6606_2.png) [@Senegoid](https://boards.straightdope.com/u/Senegoid)\
**Post date:** [December 14, 2011, 2:20am UTC](https://boards.straightdope.com/t/whats-so-great-about-the-vi-editor/606063/42 "2011-12-14T02:20:58Z")

</div>

Does anyone know QEDIT, and have any thoughts comparing that to vi?

Where is TECO when we need it?

---

<div class="post-metadata">

**Author:** ![Rysto](https://avatars.discourse-cdn.com/v4/letter/r/ecccb3/32.png) [@Rysto](https://boards.straightdope.com/u/Rysto)\
**Post date:** [December 14, 2011, 2:21am UTC](https://boards.straightdope.com/t/whats-so-great-about-the-vi-editor/606063/43 "2011-12-14T02:21:08Z")

</div>

> [@gazpacho](#):
>
> Does anybody really use vi anymore instead of vim? All the machines I have encountered in the last 5 years alias vi to vim.

OK, be honest, were any of these not Linux? Most other Unix-like systems typically don’t ship with vim by default.

---

<div class="post-metadata">

**Author:** ![Chronos](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/chronos/32/134_2.png) [@Chronos](https://boards.straightdope.com/u/Chronos)\
**Post date:** [December 14, 2011, 2:44am UTC](https://boards.straightdope.com/t/whats-so-great-about-the-vi-editor/606063/44 "2011-12-14T02:44:28Z")

</div>

I just checked, and this machine (OSX 10.6) both has vim, and opens vim when told vi. It is an improvement, in that it at least tells you when you open it what the quit command is, and automatically goes into insert mode by default… Except that it doesn’t tell you, once you’re in insert mode, how to go back to the command mode to enter that quit command.

---

<div class="post-metadata">

**Author:** ![Derleth](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Derleth](https://boards.straightdope.com/u/Derleth)\
**Post date:** [December 14, 2011, 2:53am UTC](https://boards.straightdope.com/t/whats-so-great-about-the-vi-editor/606063/45 "2011-12-14T02:53:01Z")

</div>

> [@Senegoid](#):
>
> Where is TECO when we need it?

[Right here](http://videoteco.cvs.sourceforge.net/viewvc/videoteco/videoteco/); the [reference material is here.](http://www.copters.com/teco.html) Technically, it’s Video TECO, a TECO for Unix that takes full advantage of the fact modern terminals are xterms and modern computers and networks are fast; think of it as the vi to original TECO’s ed or ex. Essentially the same command set, more fully graphical presentation.

[TECO on the TextEditor Wiki.](http://texteditors.org/cgi-bin/wiki.pl?TECO)

[“The Glorious Horror of TECO” at Good Math, Bad Math.](http://scientopia.org/blogs/goodmath/2010/11/30/the-glorious-horror-of-teco/) One of the best introductions to the editor.

---

<div class="post-metadata">

**Author:** ![black\_rabbit](https://avatars.discourse-cdn.com/v4/letter/b/f19dbf/32.png) [@black\_rabbit](https://boards.straightdope.com/u/black_rabbit)\
**Post date:** [December 14, 2011, 3:55am UTC](https://boards.straightdope.com/t/whats-so-great-about-the-vi-editor/606063/46 "2011-12-14T03:55:10Z")

</div>

> [@BigT](#):
>
> Because VI was designed to be an IDE, essentially. Most of its features are only useful to programmers. It’s not fair to compare it to text editors because that’s not what it is.

Bullpuckey. Where are the built in compilers and debugging tools?

vi is as much a text editor (and mostly only a text editor) as, say, Notepad notepad++ or Slickedit or something is a text editor. vim may have functionality to hook in to make or gcc or whatever through custom scripting, but that’s just a product of its extensibility.

Next you’re going to tell me that ed is an IDE.

---

<div class="post-metadata">

**Author:** ![J\_Cubed](https://avatars.discourse-cdn.com/v4/letter/j/c6cbf5/32.png) [@J\_Cubed](https://boards.straightdope.com/u/J_Cubed)\
**Post date:** [December 14, 2011, 3:59am UTC](https://boards.straightdope.com/t/whats-so-great-about-the-vi-editor/606063/47 "2011-12-14T03:59:55Z")

</div>

I like vi so much I use that option in my shell. I can find, modify, and execute a previous command while bash babies are still moving their hand over to the up arrow.

---

<div class="post-metadata">

**Author:** ![Colibri](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/colibri/32/1841_2.png) [@Colibri](https://boards.straightdope.com/u/Colibri)\
**Post date:** [December 14, 2011, 4:36am UTC](https://boards.straightdope.com/t/whats-so-great-about-the-vi-editor/606063/48 "2011-12-14T04:36:18Z")

</div>

Since the OP calls for opinions, let’s move this to IMHO.

Colibri  
General Questions Moderator

---

<div class="post-metadata">

**Author:** ![gonzoron](https://avatars.discourse-cdn.com/v4/letter/g/a6a055/32.png) [@gonzoron](https://boards.straightdope.com/u/gonzoron)\
**Post date:** [December 14, 2011, 4:59am UTC](https://boards.straightdope.com/t/whats-so-great-about-the-vi-editor/606063/49 "2011-12-14T04:59:19Z")

</div>

> [@BigT](#):
>
> And VS is far from the only bit of software that can do this stuff. Notepad++ is one I use. It likewise calls itself a text editor when it really is more of an IDE, with its syntax highlighting (a feature I don’t believe VI has).

vi doesn’t, but vim does.

---

<div class="post-metadata">

**Author:** ![Indistinguishable](https://avatars.discourse-cdn.com/v4/letter/i/90ced4/32.png) [@Indistinguishable](https://boards.straightdope.com/u/Indistinguishable)\
**Post date:** [December 14, 2011, 7:16am UTC](https://boards.straightdope.com/t/whats-so-great-about-the-vi-editor/606063/50 "2011-12-14T07:16:14Z")

</div>

> [@Derleth](#):
>
> Menus are terrible to navigate and they’re modal, meaning they lock you into a path which is difficult to get out of.

What do you mean by this?

---

<div class="post-metadata">

**Author:** ![si\_blakely](https://avatars.discourse-cdn.com/v4/letter/s/d9b06d/32.png) [@si\_blakely](https://boards.straightdope.com/u/si_blakely)\
**Post date:** [December 14, 2011, 8:10am UTC](https://boards.straightdope.com/t/whats-so-great-about-the-vi-editor/606063/51 "2011-12-14T08:10:15Z")

</div>

> [@Colibri](#):
>
> Since the OP calls for opinions, let’s move this to IMHO.

It is turning into a **vi/emacs/other editor** thread - surely GD would be more appropriate 😉

I use vi (or vim) because it is consistent and fast and available - even on my laptop I prefer firing up vi in a console to launching _kate_ or another gui text editor (particularly for **sudo** level edits). I never got on with emacs, I just could not get my head around it.

But I do remember the learning curve for vi, and regularly losing large chunks of my first year programming projects due to an accidental _99dd_ or similar. And things got worse under pressure. u (Undo) became my friend, as well as **:q!**. I use it a lot less now, though.

Si

---

<div class="post-metadata">

**Author:** ![Derleth](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Derleth](https://boards.straightdope.com/u/Derleth)\
**Post date:** [December 14, 2011, 10:10am UTC](https://boards.straightdope.com/t/whats-so-great-about-the-vi-editor/606063/52 "2011-12-14T10:10:03Z")

</div>

> [@Indistinguishable](#):
>
> What do you mean by this?

Terrible to navigate: Laid out by crack monkeys, at least in the general case.

Modal: When you’re in the menu, that locks you into a new mode of interaction where everything is redefined and you need to know how to get out of it to do something else.

vi is a modal editor; its whole UI is built around command mode as distinct from editing mode.

Emacs is less modal; most commands are entered using the Ctrl, Alt, or Esc keys, and typing just ‘j’ will very usually enter a ‘j’ into the current file. Some commands, like search or entering a filename, do create a specific mode where things work a bit differently.

Menus are modal and, at least some of the time, you can’t exit the mode without picking something. Worse, the very structure of a menu means that either the commands are very limited and can’t be augmented or you end up with the Massive King-Hell Menu What Ate Detroit.

I’m an Emacs user. Deep down, I believe my editor should be able to control nuclear power plants, so limiting the number of commands is inimical to my worldview.

---

<div class="post-metadata">

**Author:** ![Zerc](https://avatars.discourse-cdn.com/v4/letter/z/82dd89/32.png) [@Zerc](https://boards.straightdope.com/u/Zerc)\
**Post date:** [December 14, 2011, 12:07pm UTC](https://boards.straightdope.com/t/whats-so-great-about-the-vi-editor/606063/53 "2011-12-14T12:07:09Z")

</div>

I started with joe on slackware linux many years ago. One thing it does that vi doesn’t appear to do is highlighting of marked lines. Say I want to cut and paste an arbitrary number lines from one part of a file to another. In Joe I go to the first line mark it with ^KB, go the last line mark it with ^KK and the block is then highlighted. I move my cursor to the new place and then either move or copy the marked text with ^KM or ^KC . In vi the only way I know how to do it is to put my cursor on the first line, count the number of lines I want to copy and then yank and paste them. Is there any easier way of doing this?

Joe of course has it own set of keystrokes needed to manipulate text but it uses the same keystrokes that Wordstar used which Turbo Pascal emulated so I was at least familiar with the keystrokes from day one.

---

<div class="post-metadata">

**Author:** ![septimus](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/septimus/32/410_2.png) [@septimus](https://boards.straightdope.com/u/septimus)\
**Post date:** [December 14, 2011, 5:02pm UTC](https://boards.straightdope.com/t/whats-so-great-about-the-vi-editor/606063/54 "2011-12-14T17:02:28Z")

</div>

> [@gazpacho](#):
>
> Does anybody really use vi anymore instead of vim?

\<raises hand\>  
I found some _nvi_ source code on-line and compiled it. I don’t claim _nvi_ is “better” than _vim_ but the latter has redefined at least one common keystroke sequence I am very used to. Learning new things is good, but the “upgrade” to _vim_ has very low priority. 🆒

Just as one “knows” how to ride a bicycle without being able to explain it, I learned _vi_ 30-odd years ago and my fingers push the correct keys in common editing situations where I might have trouble telling you which keys I pressed. :smack:

Since I’m happy to use _awk_, _sed_ or (my favorite) _a.out_ for any complex editing task, _vi_ is more than good enough for my needs and any slight advantage _emacs_ (let alone _vim_) might have has never been relevant for me.

---

<div class="post-metadata">

**Author:** ![sweeteviljesus](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@sweeteviljesus](https://boards.straightdope.com/u/sweeteviljesus)\
**Post date:** [December 14, 2011, 10:45pm UTC](https://boards.straightdope.com/t/whats-so-great-about-the-vi-editor/606063/55 "2011-12-14T22:45:17Z")

</div>

> [@Colibri](#):
>
> Since the OP calls for opinions, let’s move this to IMHO.
> 
> Colibri  
> General Questions Moderator

I agree that it has degenerated into that, but what I really wanted to know was if there was a feature of vi that isn’t available on GUI editors. For the record, I use the editor included in Eclipse and you can do regex-based search and replace, although I have only done that once or twice.

Rob

---

<div class="post-metadata">

**Author:** ![filmore](https://avatars.discourse-cdn.com/v4/letter/f/7993a0/32.png) [@filmore](https://boards.straightdope.com/u/filmore)\
**Post date:** [December 14, 2011, 11:35pm UTC](https://boards.straightdope.com/t/whats-so-great-about-the-vi-editor/606063/56 "2011-12-14T23:35:24Z")

</div>

Some of the powerful things Vi does that you don’t find in GUI editors:

**Range-based operations** – The ability to perform a task within a specified range. The task could be replace, delete, or other complex tasks. Ranges can be specified as line numbers or patterns. This allows you to control where in the file an operation takes place. For example, ranges might be:

1,. - From the beginning of the file to the current line  
.,$ - From the current line to the end of the file  
100,/dog/ – From line 100 to the line which contains the pattern ‘dog’

These range-based operations allow me to modify a part of a file in a single step. In a GUI editor I would have to do operations one at a time between the range I want.

**Ability to create location markers** – I can mark places in the file with a name by pressing m and then a letter. Whatever letter I type becomes the name of that marker. I can create multiple markers and then immediately jump to those locations by using the ’ followed by the letter. So 'a would take me to the place where I marked it with ma. This is very useful when I need to jump around to different places in the file.

The markers can also be used in ranged-based operations like this:

'a,'bs/dog/canine/

This says to do the replacement of dog to canine between the lines marked with markers a and b.  
There are also many little things that Vi does that a GUI editor doesn’t. A lot of them aren’t such a big deal in a GUI environment. For example, I can read in a file at the current cursor location in Vi by using the :r command. In a GUI you would need to do some sort of cut-and-paste between the two files. Vi has a lot of those types tasks which are very useful in a simple terminal but not so important in the GUI world.

---

<div class="post-metadata">

**Author:** ![Senegoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/senegoid/32/6606_2.png) [@Senegoid](https://boards.straightdope.com/u/Senegoid)\
**Post date:** [December 15, 2011, 12:08am UTC](https://boards.straightdope.com/t/whats-so-great-about-the-vi-editor/606063/57 "2011-12-15T00:08:16Z")

</div>

> [@Zerc](#):
>
> I started with joe on slackware linux many years ago. One thing it does that vi doesn’t appear to do is highlighting of marked lines. Say I want to cut and paste an arbitrary number lines from one part of a file to another. In Joe I go to the first line mark it with ^KB, go the last line mark it with ^KK and the block is then highlighted. I move my cursor to the new place and then either move or copy the marked text with ^KM or ^KC . In vi the only way I know how to do it is to put my cursor on the first line, count the number of lines I want to copy and then yank and paste them. Is there any easier way of doing this?
> 
> Joe of course has it own set of keystrokes needed to manipulate text but it uses the same keystrokes that Wordstar used which Turbo Pascal emulated so I was at least familiar with the keystrokes from day one.

If your vi is actually vim, you can do something like this without counting lines. It has “visual” mode where you highlight text by moving the cursor with any of the cursor-moving commands. There are three varieties of visual mode. Start with one of the commands v or V or Ctrl-V then move the cursor to highlight something, then end with the command that should actually do something to that text (like y or d or whatever).

One of the visual modes does line mode, where whole lines get highlighted. One of them does character mode, where you highlight from any character to any character. And one of them does “block” mode where you can highlight a rectangular block of text and work with that.

In any of these visual modes, you _might_ be able to use the mouse too. I’m not sure how that plays everywhere. On my machine (I just tried it), this doesn’t work.

---

<div class="post-metadata">

**Author:** ![gonzoron](https://avatars.discourse-cdn.com/v4/letter/g/a6a055/32.png) [@gonzoron](https://boards.straightdope.com/u/gonzoron)\
**Post date:** [December 15, 2011, 12:20am UTC](https://boards.straightdope.com/t/whats-so-great-about-the-vi-editor/606063/58 "2011-12-15T00:20:04Z")

</div>

Admittedly, I don’t have much experience with the newer gui editors, but I’d be surprised if they could do this one, and it happens all the time in my job, and vim does it easily (though vi doesn’t, but I make sure vim is installed wherever I need it, including all my windows systems at home.)

I might need to take:  
foo(0) \<= bar(7 DOWNTO 0);

and duplicate it like this:  
foo(0) \<= bar(7 DOWNTO 0);  
foo(1) \<= bar(15 DOWNTO 8);  
foo(2) \<= bar(23 DOWNTO 16);  
foo(3) \<= bar(31 DOWNTO 24);  
foo(4) \<= bar(39 DOWNTO 32);  
foo(5) \<= bar(47 DOWNTO 40);  
foo(6) \<= bar(55 DOWNTO 48);  
foo(7) \<= bar(63 DOWNTO 56);

In vim, that’s simply qqyyp\<ctrl-A\>w8\<ctrl-A\>w.q6@q

(record macro “q”, yank 1 line, paste the line, increment next number, skip a word, increment next number 8 times, skip a word, repeat last command (increment next number 8 times), stop recording macro. execute macro “q” 6 times) (It’s the ctrl-A for “increment” that vi can’t do, and I’m doubting that a “modern” editor could do with a simple keystroke)

Yes, I recognize that looks like line noise to a non-vi user, but that’s part of the charm. most geeks enjoy being able to do things that mystify the layman. I’ll admit there’s no small amount of elitism, or if you prefer, the pride in mastering a complex and daunting system, in the love of vi. But there are times (and not rare times) especially at work, where I can’t imagine how else I’d do some task if not for vi (i.e. vim).

---

<div class="post-metadata">

**Author:** ![Senegoid](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/senegoid/32/6606_2.png) [@Senegoid](https://boards.straightdope.com/u/Senegoid)\
**Post date:** [December 15, 2011, 12:23am UTC](https://boards.straightdope.com/t/whats-so-great-about-the-vi-editor/606063/59 "2011-12-15T00:23:40Z")

</div>

> [@Zerc](#):
>
> I started with joe on slackware linux many years ago. One thing it does that vi doesn’t appear to do is highlighting of marked lines. Say I want to cut and paste an arbitrary number lines from one part of a file to another. In Joe I go to the first line mark it with ^KB, go the last line mark it with ^KK and the block is then highlighted. I move my cursor to the new place and then either move or copy the marked text with ^KM or ^KC . In vi the only way I know how to do it is to put my cursor on the first line, count the number of lines I want to copy and then yank and paste them. Is there any easier way of doing this?
> 
> Joe of course has it own set of keystrokes needed to manipulate text but it uses the same keystrokes that Wordstar used which Turbo Pascal emulated so I was at least familiar with the keystrokes from day one.

Notwithstanding my comment just above about vi, I will second that I really like the WordStar command style. It uses control characters for commands, so no input mode vs. command mode. The vi style was good back in the day when we used teletypes that didn’t have F-keys or numeric keypads, and often connected via modems that did their own things with control characters.

vi had a characteristic that the command set was well thought out and well structured. If you learned just a few commands, you could quickly intuit a great many more. vi was the first screen-oriented editor I ever heard of or saw or used, back in 1979. One of my office-mates showed it to me. It just totally blew his mind away when he showed me about 5 commands and I instantly guessed dozens of others.

Compare/contrast with Emacs and any WordStyle editor: The WordStar style commands use control characters, but no input/text modes. The commands are well thought out and, like vi, you can readily intuit many commands after learning just a few. Many of them, even more so than vi, have mnemonic value, even if you have to think about it sometimes. (Example: Various commands having to do with the beginning of a block involve the letter B. Various commands dealing with the end of a block involve the letter K. WTF? Because B and K are the beginning and end letters of the word BlocK.) Some other commands derive mnemonic value just from their position on the keyboard, like ^A and ^F being just to the outsides of ^S and ^D.

I first learned WordStar commands from really using WordStar on an Apple II that was tricked up (by addition of a card) to run the Intel 8080 instruction set, whereby we ran CP/M and WordStar. (Remember CP/M?) The command set must have been a real success – umpty-ump editors since have used it, including Microsoft’s DOS EDIT.

The editor QEDIT (also simply called Q) that I mentioned a few posts above also uses the WordStar set, basically.

My attitude: One-and-half thumbs up for vi/vim. Two thumbs up for WordStar and its followers.

Like another post mentioned, I never really got my head into Emacs. Too many commands just don’t have the mnemonic value (at least that works for me), and there are too many common commands that require multiple (often more than two) keystrokes.

---

<div class="post-metadata">

**Author:** ![gonzoron](https://avatars.discourse-cdn.com/v4/letter/g/a6a055/32.png) [@gonzoron](https://boards.straightdope.com/u/gonzoron)\
**Post date:** [December 15, 2011, 12:27am UTC](https://boards.straightdope.com/t/whats-so-great-about-the-vi-editor/606063/60 "2011-12-15T00:27:10Z")

</div>

> [@Senegoid](#):
>
> If your vi is actually vim, you can do something like this without counting lines. It has “visual” mode where you highlight text by moving the cursor with any of the cursor-moving commands. There are three varieties of visual mode. Start with one of the commands v or V or Ctrl-V then move the cursor to highlight something, then end with the command that should actually do something to that text (like y or d or whatever).

If it’s just a matter of picking out certain lines, you can do this without visual mode (which I do use sometimes, but it feels like cheating. 🙂 ) simply mark the first line with bookmark (ma, for example) and then move to the last line and use this command to yank from the bookmark to the current line:  
:'a,.y

It won’t be highlighted, but you won’t have to count lines.

> [@](#):
>
> And one of them does “block” mode where you can highlight a rectangular block of text and work with that.

Yeah, that’s another useful vim-ism. MSword can do by holding alt and using the mouse, but it’s a lot easier and more accurate with vim’s ctrl-v block highlighting.

[Previous page](https://boards.straightdope.com/t/whats-so-great-about-the-vi-editor/606063.md?page=2)

[Next page](https://boards.straightdope.com/t/whats-so-great-about-the-vi-editor/606063.md?page=4)
