My Android phone runs plain vi in the terminal.
Does anyone know QEDIT, and have any thoughts comparing that to vi?
Where is TECO when we need it?
OK, be honest, were any of these not Linux? Most other Unix-like systems typically don’t ship with vim by default.
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.
Right here; the reference material is here. 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.
“The Glorious Horror of TECO” at Good Math, Bad Math. One of the best introductions to the editor.
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.
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.
Since the OP calls for opinions, let’s move this to IMHO.
Colibri
General Questions Moderator
vi doesn’t, but vim does.
What do you mean by this?
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
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.
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.
<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.
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
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.
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.
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).
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.
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.
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.