# vi, emacs or copy con foo.exe?

**URL:** <https://boards.straightdope.com/t/vi-emacs-or-copy-con-foo-exe/506762>\
**Category:** In My Humble Opinion\
**Created:** [August 17, 2009, 6:34pm UTC](https://boards.straightdope.com/t/vi-emacs-or-copy-con-foo-exe/506762 "2009-08-17T18:34:11Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Digital\_Stimulus](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@Digital\_Stimulus](https://boards.straightdope.com/u/Digital_Stimulus)\
**Post date:** [August 17, 2009, 11:42pm UTC](https://boards.straightdope.com/t/vi-emacs-or-copy-con-foo-exe/506762/21 "2009-08-17T23:42:18Z")

</div>

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…

> [@ZenBeam](#):
>
> B) Select a Column of data (or other characters), Cut that column, and paste it into a different location.

Use ctrl+v in command mode to column select (e.g., first [blog explanation](http://sethmason.com/blog/23/vim-tip-select-column) 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.

---

<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:** [August 18, 2009, 1:00am UTC](https://boards.straightdope.com/t/vi-emacs-or-copy-con-foo-exe/506762/22 "2009-08-18T01:00:45Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Hyperelastic](https://avatars.discourse-cdn.com/v4/letter/h/a3d4f5/32.png) [@Hyperelastic](https://boards.straightdope.com/u/Hyperelastic)\
**Post date:** [August 18, 2009, 1:07am UTC](https://boards.straightdope.com/t/vi-emacs-or-copy-con-foo-exe/506762/23 "2009-08-18T01:07:13Z")

</div>

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.

---

<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:** [August 18, 2009, 1:20am UTC](https://boards.straightdope.com/t/vi-emacs-or-copy-con-foo-exe/506762/24 "2009-08-18T01:20:52Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)\
**Post date:** [August 18, 2009, 1:45am UTC](https://boards.straightdope.com/t/vi-emacs-or-copy-con-foo-exe/506762/25 "2009-08-18T01:45:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![friedo](https://avatars.discourse-cdn.com/v4/letter/f/8edcca/32.png) [@friedo](https://boards.straightdope.com/u/friedo)\
**Post date:** [August 18, 2009, 1:47am UTC](https://boards.straightdope.com/t/vi-emacs-or-copy-con-foo-exe/506762/26 "2009-08-18T01:47:46Z")

</div>

> [@Chronos](#):
>
> 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.

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. 🙂 )

---

<div class="post-metadata">

**Author:** ![Risha](https://avatars.discourse-cdn.com/v4/letter/r/5fc32e/32.png) [@Risha](https://boards.straightdope.com/u/Risha)\
**Post date:** [August 18, 2009, 2:07am UTC](https://boards.straightdope.com/t/vi-emacs-or-copy-con-foo-exe/506762/27 "2009-08-18T02:07:29Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![QuercusMax](https://avatars.discourse-cdn.com/v4/letter/q/8baadc/32.png) [@QuercusMax](https://boards.straightdope.com/u/QuercusMax)\
**Post date:** [August 18, 2009, 2:35am UTC](https://boards.straightdope.com/t/vi-emacs-or-copy-con-foo-exe/506762/28 "2009-08-18T02:35:54Z")

</div>

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.).

---

<div class="post-metadata">

**Author:** ![minor7flat5](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/minor7flat5/32/258_2.png) [@minor7flat5](https://boards.straightdope.com/u/minor7flat5)\
**Post date:** [August 18, 2009, 2:46am UTC](https://boards.straightdope.com/t/vi-emacs-or-copy-con-foo-exe/506762/29 "2009-08-18T02:46:37Z")

</div>

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](http://en.wikipedia.org/wiki/Busybox), which has an anemic vi implementation.

---

<div class="post-metadata">

**Author:** ![Giraffe](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/giraffe/32/129_2.png) [@Giraffe](https://boards.straightdope.com/u/Giraffe)\
**Post date:** [August 18, 2009, 3:48am UTC](https://boards.straightdope.com/t/vi-emacs-or-copy-con-foo-exe/506762/30 "2009-08-18T03:48:31Z")

</div>

> [@Belrix](#):
>
> Of course, we all know that emacs is a nifty little OS that masquerades as an editor.

> [@Telemark](#):
>
> MIT Rule of Software - All programs expand until they can read mail.

> [@Hyperelastic](#):
>
> Emacs Makes A Computer Slow

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.

---

<div class="post-metadata">

**Author:** ![Belrix](https://avatars.discourse-cdn.com/v4/letter/b/ed655f/32.png) [@Belrix](https://boards.straightdope.com/u/Belrix)\
**Post date:** [August 18, 2009, 4:01pm UTC](https://boards.straightdope.com/t/vi-emacs-or-copy-con-foo-exe/506762/31 "2009-08-18T16:01:40Z")

</div>

> [@ZenBeam](#):
>
> I’ve _heard_ of awk. Of course, I still don’t know how to swap the columns _using_ awk…
> 
> I should mention that in emacs, I don’t need to know how many lines of data there are, which line is the beginning or ending line, or the beginning and ending column numbers.

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

---

<div class="post-metadata">

**Author:** ![ZenBeam](https://avatars.discourse-cdn.com/v4/letter/z/3ab097/32.png) [@ZenBeam](https://boards.straightdope.com/u/ZenBeam)\
**Post date:** [August 18, 2009, 4:48pm UTC](https://boards.straightdope.com/t/vi-emacs-or-copy-con-foo-exe/506762/32 "2009-08-18T16:48:06Z")

</div>

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.

> [@Digital\_Stimulus](#):
>
> Use ctrl+v in command mode to column select (e.g., first [blog explanation](http://sethmason.com/blog/23/vim-tip-select-column) from google). Cut and paste are the usual key commands.

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…

---

<div class="post-metadata">

**Author:** ![ZenBeam](https://avatars.discourse-cdn.com/v4/letter/z/3ab097/32.png) [@ZenBeam](https://boards.straightdope.com/u/ZenBeam)\
**Post date:** [August 18, 2009, 4:55pm UTC](https://boards.straightdope.com/t/vi-emacs-or-copy-con-foo-exe/506762/33 "2009-08-18T16:55:00Z")

</div>

> [@Giraffe](#):
>
> 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.

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

😃

---

<div class="post-metadata">

**Author:** ![Redwing](https://avatars.discourse-cdn.com/v4/letter/r/dfb087/32.png) [@Redwing](https://boards.straightdope.com/u/Redwing)\
**Post date:** [August 18, 2009, 5:41pm UTC](https://boards.straightdope.com/t/vi-emacs-or-copy-con-foo-exe/506762/34 "2009-08-18T17:41:02Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Digital\_Stimulus](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@Digital\_Stimulus](https://boards.straightdope.com/u/Digital_Stimulus)\
**Post date:** [August 18, 2009, 6:09pm UTC](https://boards.straightdope.com/t/vi-emacs-or-copy-con-foo-exe/506762/35 "2009-08-18T18:09:59Z")

</div>

> [@ZenBeam](#):
>
> Checking the dates, a little over a year ago vi was replaced with a link to vim.

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

> [@](#):
>
> 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?

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](http://www.pixelbeat.org/vim.tips.html). I hope that all helps some…

---

<div class="post-metadata">

**Author:** ![Superfluous\_Parentheses](https://avatars.discourse-cdn.com/v4/letter/s/8edcca/32.png) [@Superfluous\_Parentheses](https://boards.straightdope.com/u/Superfluous_Parentheses)\
**Post date:** [August 18, 2009, 7:34pm UTC](https://boards.straightdope.com/t/vi-emacs-or-copy-con-foo-exe/506762/36 "2009-08-18T19:34:33Z")

</div>

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? 😃

ETA:

> [@Belrix](#):
>
> Of course, we all know that emacs is a nifty little OS that masquerades as an editor.

And that’s exactly what makes it so wonderful.

---

<div class="post-metadata">

**Author:** ![Giraffe](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/giraffe/32/129_2.png) [@Giraffe](https://boards.straightdope.com/u/Giraffe)\
**Post date:** [August 18, 2009, 8:01pm UTC](https://boards.straightdope.com/t/vi-emacs-or-copy-con-foo-exe/506762/37 "2009-08-18T20:01:27Z")

</div>

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. 🙂

---

<div class="post-metadata">

**Author:** ![Unintentionally\_Blank](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/unintentionally_blank/32/5418_2.png) [@Unintentionally\_Blank](https://boards.straightdope.com/u/Unintentionally_Blank)\
**Post date:** [August 18, 2009, 8:23pm UTC](https://boards.straightdope.com/t/vi-emacs-or-copy-con-foo-exe/506762/38 "2009-08-18T20:23:51Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![kelly5078](https://avatars.discourse-cdn.com/v4/letter/k/6f9a4e/32.png) [@kelly5078](https://boards.straightdope.com/u/kelly5078)\
**Post date:** [August 18, 2009, 9:28pm UTC](https://boards.straightdope.com/t/vi-emacs-or-copy-con-foo-exe/506762/39 "2009-08-18T21:28:32Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ZenBeam](https://avatars.discourse-cdn.com/v4/letter/z/3ab097/32.png) [@ZenBeam](https://boards.straightdope.com/u/ZenBeam)\
**Post date:** [August 18, 2009, 9:34pm UTC](https://boards.straightdope.com/t/vi-emacs-or-copy-con-foo-exe/506762/40 "2009-08-18T21:34:10Z")

</div>

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

> [@](#):
>
> (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.)

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

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

> [@](#):
>
> Can you navigate emacs on a text connection with no arrow keys?

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.

[Previous page](https://boards.straightdope.com/t/vi-emacs-or-copy-con-foo-exe/506762.md?page=1)

[Next page](https://boards.straightdope.com/t/vi-emacs-or-copy-con-foo-exe/506762.md?page=3)
