vi, emacs or copy con foo.exe?

vi(m), especially after I had to admin a SunOS machine remotely one time. I’m not even sure there was another editor on there…

Use ctrl+v in command mode to column select (e.g., first blog explanation from google). Cut and paste are the usual key commands.

Never bothered with mid-line cutting/pasting, so I don’t have that info off the top of my head.

I avoid both like the plague, but when I’m forced to edit things from the command line I use vi. I can at least do basic editing with it.

Emacs Makes A Computer Slow
but it’s still better than vi, which I personally believe was technological sabotage introduced by Soviet hackers attempting to ruin productivity.

Real programmers know that the whole purpose of the computer is to do tedious arcane work so you don’t have to. I use pico, because it doesn’t make me go through all the tedium that vi does. It’s a simple tool for a simple job. I’ll grant that emacs has a valid role, since even though it’s much more complicated, it can also do more complicated things. But vi is a complicated tool for a simple job, and such a tool has no place in my toolbox.

I actually use both. Whenever I need to tweak a conf file, or write a svn commit message, or do other brief, mundane tasks, I generally use vim.

But for any real programming, it has to be Emacs. There is no comparison, especially if you start learning some elisp.

Pico was the first console mode editor I learned to use, because it was the default editor for Pine.

Does Pico do any syntax highlighting, or delimiter matching, etc? Because those are the big features that I find invaluable in both Emacs and vim. (Of course, Emacs does it much, much better. :slight_smile: )

Only masochists use vi. Well, them and the sadists that make their students use vi. :mad:

Definitely VIM. Although if I’m doing Java (80% of my coding) I’ll do it in Eclipse, and ObjC (10%) I’ll use Xcode. But for shell scripts/ruby/commit messages/sysadmin tasks, it’s vim all the way.

I wrote my master’s thesis using vim and LaTeX. I used emacs for a little while when I was in high school, but vi is EVERYWHERE that counts, and works much nicer over slower connections (when I’m ssh’d into a server in China, e.g.).

Bare-bones vi all the way.

I prefer being able to plop down in front of any Unix or Linux server in any condition and very quickly edit files.

The only time I have ever run into trouble is with small embedded Linux devices, such as routers. Quite often they don’t include vi, so I have to make do with nano or pico, whichever they tossed in.

This is odd because most embedded distros are based on busybox, which has an anemic vi implementation.

I’m telling you, you’re all talking about XEmacs, which is a bloated and retarded program. Proper GNU emacs is wonderful and light as a feather.

Since you want to preserve the header:

awk ‘{if(NR>1){print $1,$3,$2}else {print}}’ inputfile

formatted:

awk ‘{if(NR>1){printf("%4d %4d %4d
",$1,$3,$2)} else {print}}’ inputfile

I have a post-it here at work with things I can’t do using vi. In addition to the two I mentioned above,

C) Search and Replace some, but not all, occurrences of a string with a second string.
D) Page Down.

I just tried using the PageDown key on a system here, and it worked. Checking the dates, a little over a year ago vi was replaced with a link to vim. So at least I can do one of the four.

That example isn’t quite what I want. I was able to cut a rectangle using vim, and presumably I could paste it also, but I couldn’t figure that part out. Anyone?

On another system with vi, but not vim, neither of the above works.

BTW, that awk command will swap columns in the same line, but I don’t think it will work if I want to paste a column into a different set of lines. Not that I’m going to try to learn awk anyway…

:rolleyes: Yes, a built-in psychotherapist is a core service, not bloat. An adventure game too…

:smiley:

vi, because it’s so much better than ed. I don’t use emacs, because it wasn’t available to the of universality that vi was while I was learning. I expect any unix admin that I deal with to know it, and I train all junior admins to use it. I’m just happy that I can get it with most minikernal boots when I have to repair something. I still make sure I can get by with ed, if I have to, never know what kind of legacy mess someone’s going to drop on me next month.

Pagedown in vi is ctrl+f, PageUp is ctrl+b. Can you navigate emacs on a text connection with no arrow keys?

Ah. I don’t remember the last time I used plain-vanilla vi, so I’m little help there.

Just to be sure: you couldn’t figure out how to paste what you had cut? OK, here’s more detail; I’m testing while I type this up, so as not to inflict my faulty memory on you. Also note that all the following is for vim, not vi.

In command mode, “v” turns on “visual marking” and “ctrl-v” turns on “visual block” (i.e., column marking). As I just re-discovered, the former will do the “half-line marking” you mentioned above. After you “turn on” the marking, all the usual cursor movement commands are in operation. That is:

“v” + “9” + “downarrow” will mark 9 lines (i.e., include 9 end-of-lines) from the cursor’s origin towards the end of the file.

“ctrl-v” + “9” + “downarrow” will mark a 1 character wide, 9 line column.

When column marking, of course, you can also add a number and right/left arrow to widen your column. So:

“ctrl-v” + “9” + “downarrow” + “5” + “rightarrow” will mark a 9 row, 5 column rectangle.

Naturally, the left/right arrow works in line block also, it just performs the commands sequentially – using “v” rather than “ctrl-v”, the above would simply select 9 lines and 5 extra characters.

Once the selection is marked, you can then use the usual “y” to yank (i.e., copy), “d” to delete (i.e., cut), and “p” to paste. (Keep in mind “u” to undo any oopsies. I forget how many undos are maintained, but I don’t think I’ve ever hit the limit.)

Sorry about the fair uselessness of my previous link; here’s a better one of vim essentials. I hope that all helps some…

Emacs forever!

Though I like vi as an “inline” editor (things like git rebase -i editing) better than emacsclient. On the other hand, emacs has modes for pretty much everything I do, so I hardly need vi for even that.

Also: vi doesn’t even run a lisp. What’s that about? :smiley:

ETA:

And that’s exactly what makes it so wonderful.

This thread would have been better with a poll, by the way. I’d like to see how many vi-tards there are out there. :slight_smile:

What, emacs can’t scrape the page and tell you that? :slight_smile:

When absolutely forced, I’ll use vi. But I generally make sure I have X and use a notepad-style text editor instead.

Thanks Digital Stimulus, that works in vim. I can now do A, B, and D. Only C remains.

Heh. Much better than “<esc>:q!”, which is what I had been using.

Thanks for the <ctl>f and <ctl>b Redwing.

Sure! Ummmm… <Pulls down Gnu Emacs manual and blows dust off top of book>
To move up or down a line, use <ctl>p or <ctl>n (previous and next). <ctl>f or <ctl>b go forward or back one character. <meta>f or <meta>b go forward or back one word. (<meta> seems to be <Alt> on windows. If there’s no <meta> key, you can use <Esc> (and release it) followed by the character.) To go to a particular line number (say 121), enter <meta>x goto-line <Return> 121 <Return>. <ctl>a or <ctl>e go to beginning or end of line. <meta>< or <meta>> got to beginning or end of document (or use <ctl><home> and <ctl><end>).

To cut text to the end of a line, use <ctl>k. Repeat <ctl>k to remove the newline as well. To cut an arbitrary section of text, enter <ctl><space> at one end, navigate to the other end, and then enter <ctl>f. Use <ctl>v to paste. “copy” is just <ctl>f followed by <ctl>v or <ctl>_ (the undo command). Instead of <ctl>f, use “<meta>x kill-rect” to cut a rectangle of text. “<meta>x yank-rect” is used to paste the rectangle. Again, no “copy”, I just use undo. You can also use the mouse to specify the region to cut (click, drag, unclick).

<ctl>l centers the visible portion of the file on the current line.

I don’t see a similar keyboard command for PageUp or PageDown using letter keys instead. There is the <ctrl>u command, which executes the following command four times, and which can be performed multiple times, so <ctrl>u <ctrl>u <ctrl>u <ctrl>n moves down 64 lines. I’m going to have to remember that one. <ctl>PageUp and <ctl>PageDown will page to the left or right, useful if you have word wrap turned off.

To do item C, enter <meta><shift>5, type in the text to search for then <Ret> then the new text, then <Ret>. The cursor will move to the next occurance of the text. Enter <space> to make the change, or <Del> to skip it. The cursor then moves to the next occurance. At any time, you can enter ! to accept all the changes to the end of the file.

These commands can be changed on your personal account. For a long time, I had <ctl><home> and <ctl><end> set for beginning and end of line, I think because the editor I was using just before emacs worked that way.

Oh, and there are multiple buffers, so you can edit several files at once in a single window, switching between them using <ctl>x b. To see two (or more) files at once, split the screen vertically or horizontally using <ctl>x 2 or <ctl>x 3. Use <ctl>x 0 to unsplit the screen.

Browsing the manual, it seems that emacs has two vi emulators you can try, if you want the worst of both worlds.

I do want to be able to use vim, since the system I want to use it on is through a slow connection. Emacs opens in its own window in Windows, and is very slow to respond. Older versions used to be able to run in the command line window, like vi does. If anyone knows how to force emacs to run that way, without all the graphical stuff, let me know.