Why does anyone use Vi?

I guess it was good back in 1982 but there are so many better editors now like emacs.

Yes, I know it’s always on linux/unix but it’s not like other editors are hard to get or cost money.

Is this OP for real? Are you planning on doing little-endian vs big-endian next?

I use it. Mainly because its always installed, and can be opened in a terminal.

It’s there, it’s fast, and the basic commands are the same regardless of what kind of system you’re on. I know vim has lots of fancy modes to do things, but in general, it gets out of your way and lets you edit a file.

That being said, I use emacs for all kinds of stuff, from a calculator, news/mail reader, to writing academic papers and software. I very, very rarely use emacs after typing “sudo”. In my system administrator hat “sudo vi” is an incredibly common thing for me to use, because vi is a known quantity. It’s not going to do anything that I don’t tell it to, and :q! saved me more than a few times when I’ve told it to do something remarkably stupid.

I know emacs can do all of that, but my thinking usually goes something like: I’m at a command line, doing something, and I need to make a quick change to a file, so running vi right there is far easier than going over to my emacs window, using tramp to open a file on another machine, or to open it as root on the local machine, etc.

Are there systems where the people who run it are so lazy they only have vi?

It’s there, it’s fast, and it doesn’t require Ctrl-Alt-Meta-L-C! for “Learning Curve” like Emacs, and doesn’t screw with my formatting like Nano/Pico.

Also, I second the used of it as a sysadmin tool because :q! is your one true god.

It doesn’t have a learning curve? What does that mean? Since I have never used Vi don’t I have to learn it to use it?

Everything that echoreply said. I even install command line vim on every PC I use.
Years ago it was more common to work on one desktop machine and connect to one or two Unix boxes. Folks would really get settled in and tweak their personal settings just right.

These days I find myself connecting to any number of odd Linux boxes, often virtual, always configured by some contracted sys admin group I never see. So, it was more expedient to become proficient in the greatest “lowest common denominator” across the Unix/Linux world: vi.

In a huge corporation it is quite common to be given a slice of some random box with a boring name that consists of digits and letters, possibly virtual, in some distant data center. It is one of thousands of servers. Maybe they provided Emacs, maybe Xemacs. Maybe it’s a bare bones install without either. I don’t worry about trying to submit a ticket to get someone to install an editor for me. vi is there already. Software configuration gets more challenging when you introduce concepts such as zones and domains that appear as separate servers but share some software.

If it sounds weird that such a common tool as emacs would be absent, it happens. I remember being puzzled at an important meeting some years back where the big topic of the hour was why the common utility “top” was not installed on our expensive new machines.

I recently started migrating to vim from emacs, just because I got tired of being the only emacs guy. When I started in the business, I could’ve gone either way, but everyone at my first company used emacs (mostly MIT guys), so I gravitated toward emacs.

If you can do i, ESC, x, and :x you can effectively use vi. There are many other commands you can learn, which will make your life easier, and a search will turn up many useful cheat sheets.

If you don’t want to use vi, then don’t. It certainly has a “learning curve”, but the first few steps are pretty easy. There’s no on screen prompts (such as an “edit” menu) so it can be quite intimidating to somebody who’s never seen it before.

After getting tendinitis in both arms because of all of the chording, I switched to Vim, and have stuck with it for over a dozen years. Pain is much less.

Yes. There are lots of systems like fileservers or nodes in computer clusters that don’t have much installed beyond the default and whatever specific programs they have for whatever their specialized task is.

Plus even if all systems have something other then vi installed “something else” isn’t always the same something else.

Vi has a relatively shallow learning curve. Every significant VI command fits on a two-page cheat sheet.

Of commands you use every day, that’s two lines.

If you type ‘vi’ into the terminal on a Mac, you get Vim – Vi IMproved.

I consider it one of my best professional achievements that I have never learned how to use VI or emacs. Good Lord, people, WTF? Why in the world would you want to use one of those archaic hard-to-use things when there are so many other options available?

It sounds like the reasons for using vi are the same reasons I use notepad on a Windows computer.

Strangely enough, I can’t even remember what editor I used on Unix in the eighties. I just remember it was real easy to use with the function keys on my terminal.

My old hardware guru guy told me he uses Vi because he absolutely needs to leave no footprints anywhere on a system. If it is Unix, or any of its many flavors, he uses Vi because “loading something” is simply not an acceptable option, no matter how superior, cheaper, and less obtuse it is. It isn’t his equipment; it isn’t even his virtual server. He is there to accomplish something, and has very little time to waste. So, he learned to use the tool that would always be available, and never need to be configured, installed, or otherwise messed with.

“They don’t want to know how you fixed the problem. They don’t even want to know what the problem was. All they want is to not have a problem.”

Tris

Huh. The old teletype in the corner just chattered to life. Let’s see what it says…

“HOLY WAR TAKEN. RETURN IF FOUND.”

I’ve used Vim and Emacs, honestly, neither of them are hard to use as just simple text editors, the hardest part (speaking as somebody who was new to both within the last 2-3 years) is:

Vim –
Realizing you have to actually enter a special insert mode to type things, and the “normal” mode is for commands and patterns.

Emacs –
Learning the key commands for save and quit.

A lot of people are saying “they’re not bad to use if you don’t need the complicated stuff” and while that’s true, I often don’t see a reason to not use gedit, which has come standard on every Linux install I’ve ever had. Hell, at least gedit’s syntax highlighting isn’t a complete eyesore (yeah yeah, you can customize it, but gedit’s is pretty out of the box). I can understand the sysadmin no footprint thing, but aside from that if you’re not doing anything complicated you probably don’t need to use vi or emacs.