Author Topic: vim or emacs?  (Read 7107 times)

0 Members and 1 Guest are viewing this topic.

Offline hashbaz

  • Grand Ancient One
  • * Moderator Emeritus
  • Thread Starter
  • Posts: 5057
  • Location: SF Bae Area
vim or emacs?
« on: Sat, 30 July 2011, 00:49:47 »
I'm curious as to where geekhackers' loyalties lie.  What do you use, for what tasks, and why?

I'm a vim man myself.  I use it for as much of my text editing as possible (chiefly coding and email).  I've made several attempts to get past the early stages of emacs proficiency, but I just like vim's modal editing model too much.  When I get going in hack mode I feel like I'm shaping text like a carpenter shapes wood.  I think vim's t and f search motions, especially when combined with d, c, v, and semi-colon/comma, are its single greatest feature.

So, vim or emacs, or something else?

Offline keyboardlover

  • Posts: 4022
  • Hey Paul Walker, Click It or Ticket!
    • http://www.keyboardlover.com
vim or emacs?
« Reply #1 on: Sat, 30 July 2011, 00:57:36 »
Notepad++

Offline Brodie337

  • Posts: 414
vim or emacs?
« Reply #2 on: Sat, 30 July 2011, 01:16:58 »
I'm a vim man too. Took alot more learning than I thought, but I'm glad I did.

Offline sordna

  • Posts: 2249
vim or emacs?
« Reply #3 on: Sat, 30 July 2011, 03:30:04 »
vim! Best feature for me is the * and # searching! And readline of / and : commands. And cindent. And, and, and, ...
Kinesis Contoured Advantage & Advantage2 LF with Cherry MX Red switches / Extra keys mod / O-ring dampening mod / Dvorak layout. ErgoDox with buzzer and LED mod.
Also: Kinesis Advantage Classic, Kinesis Advantage2, Data911 TG3, Fingerworks Touchstream LP, IBM SSK (Buckling spring), Goldtouch GTU-0077 keyboard

Offline Minskleip

  • Posts: 230
vim or emacs?
« Reply #4 on: Sat, 30 July 2011, 06:09:46 »
Nvi; Emacs (viper-mode) for Lisp.
What\'s in the back of my car? A cdr lol

Split Tipro keyboard with R3 keycaps

Offline TacticalCoder

  • Posts: 526
vim or emacs?
« Reply #5 on: Sat, 30 July 2011, 07:42:40 »
Vim/emacs war : )

When it's between vim or Emacs it's mostly Emacs for me but a quite customized Emacs where I move the cursor and do selection in a vi-style (because Emacs's default CTRL-F / CTRL-B etc. simply hardly makes any sense whatsoever).  I also remapped ctrl-x-map to something else than CTRL-x because that one is seriously hard to do when you remap caps-lock to act as a ctrl (and anyway ctrl-x is not convenient).

Emacs is really powerful that said.  Just an example: the other day I was maintaining some old and kinda crappy codebase where a lot of constants where hardcoded into some source code file and one new constant had to be introduced in the middle of two other (don't ask, not my call ; ) and we didn't have the time to rewrite everything.  The code was looking like this:

Code: [Select]

SOME_SILLY_STUFF = 21;
SOME_OTHER_SILLY_STUFF = 25;
STATE_A1 = 23;
STATE_A2 = 24;
STATE_A3 = 26;
STATE_B1 = 29;
STATE_B1 = 27;
STATE_B1 = 28;
STATE_B1 = 30;
... (here comes lots of lines that I do not want to modify manually)
STATE_Z1 = 86;


And I had to insert a "STATE_A4 = 29" and hence increment all the subsequent hardcoded constants (once again, not my call).

Under Emacs, such kind of manipulation are trivial.  In this case, it's a query-replace-regexp followed by simply this:
Code: [Select]

\b[0-9][0-9]\b
\,(1+ \#&)


The first line is the regexp: whatever, it's one way to match what I need to match.

The second line is the Emacs / Lisp killer: the '\' indicates I want to use Lisp to calculate my replacement string: (1+ every_match)

That's right: in less than 30 keystrokes all in all I did use some Lisp to add 1 to all the 70 values or so that needed it.  30 keystrokes and Lisp.  That's how powerful Emacs is.  

I know a lot of people who, faced with the same problem, would have used much, much, more than 30 keystrokes to fix the problem.

There are Emacs videos on YouTube where people much more skilled with Emacs than I am show what they can do.  It makes people's jaw drop : )

The following one is always a good read (a bit provocative and very cool):

http://www.paulgraham.com/lisp.html

:)
HHKB Pro JP (daily driver) -- HHKB Pro 2 -- Industrial IBM Model M 1395240-- NIB Cherry MX 5000 - IBM Model M 1391412 (Swiss QWERTZ) -- IBM Model M 1391403 (German QWERTZ) * 2 -- IBM Model M Ambra -- Black IBM Model M M13 -- IBM Model M 1391401 -- IBM Model M 139? ? ? *2 -- Dell AT102W -- Ergo (split) SmartBoard (white ALPS apparently)

Offline ch_123

  • * Exalted Elder
  • Posts: 5860
vim or emacs?
« Reply #6 on: Sat, 30 July 2011, 07:51:32 »
I use Geany a lot, even under Windows where I prefer it to Notepad++. Usually vim if I need to use something on the command line, but I generally don't.
« Last Edit: Sat, 30 July 2011, 07:54:40 by ch_123 »

Offline czarek

  • Posts: 627
  • Location: Poland
  • Keep the momentum going!
    • FalbaTech
vim or emacs?
« Reply #7 on: Sat, 30 July 2011, 07:57:48 »
On desktop (Mac): BBedit, on server Vi (I use BSD mainly), or ViM (when I have to deal with linux server). I have used ViM as a primary editor in the past, just when the project started on Amiga platform.
My little ErgoDox / GH60 factory: http://falbatech.pl

Offline The Solutor

  • Posts: 2262
vim or emacs?
« Reply #8 on: Sat, 30 July 2011, 08:22:11 »
mcedit in linux, notepad2 or notepad++ in windows
The problem with quotes on the Internet is you never know if they are true  (Abraham Lincoln)

Offline iMav

  • geekhack creator/founder
  • Location: Valley City, ND
  • "Τα εργαλεία σας είναι σημαντικά."
vim or emacs?
« Reply #9 on: Sat, 30 July 2011, 08:27:38 »
I really like TextMate on Mac.  However, even on the Mac I find myself using vi more then anything else.

Offline keyboardlover

  • Posts: 4022
  • Hey Paul Walker, Click It or Ticket!
    • http://www.keyboardlover.com
vim or emacs?
« Reply #10 on: Sat, 30 July 2011, 09:17:19 »
In Windows besides Notepad++ I've found that Textpad is the best for loading & searching through humongous log files. I still don't know how it can handle those multi-gig logs so easily.

Offline aggiejy

  • ** Moderator Emeritus
  • Posts: 1126
  • Location: ~Austin, Texas
vim or emacs?
« Reply #11 on: Sat, 30 July 2011, 09:30:11 »
Textmate on Mac. Vim occasionally. Coding in Xcode just because you lose too much by using anything else. (or are toggling constantly)

Offline czarek

  • Posts: 627
  • Location: Poland
  • Keep the momentum going!
    • FalbaTech
vim or emacs?
« Reply #12 on: Sat, 30 July 2011, 10:11:01 »
Quote from: aggiejy;389886
Coding in Xcode just because you lose too much by using anything else. (or are toggling constantly)
Yeah forgot to mention that - on those rare occasions I have to do some C/C++ I'm using Xcode too. And I almost don't program in Objective-C, used to do that in a past but haven't done it for some time now. At the moment I'm full time Perl programmer and for that one BBedit rocks.
My little ErgoDox / GH60 factory: http://falbatech.pl

Offline TacticalCoder

  • Posts: 526
vim or emacs?
« Reply #13 on: Sat, 30 July 2011, 10:11:07 »
Quote from: aggiejy;389886
Textmate on Mac. Vim occasionally. Coding in Xcode just because you lose too much by using anything else. (or are toggling constantly)


I've got my both my IDE and my Emacs set to auto-synch on any file change so that when I change in on or the other changes are instantly reflected on the other (and switching from one to the other is one shortcut).  There have been talks about having IDEs allowing to allow for the integration of any text editor and I'd sure love to see this happen : )

Forgot to mention in my first post: regarding remote file editing that's what Emacs's "C-x C-f  /ssh:user@host:file" is for (or you can also open a full-blown terminal inside Emacs using M-x term and do any SSH'ing you want an of course run emacs inside the outter emacs' terminal if you want to).
HHKB Pro JP (daily driver) -- HHKB Pro 2 -- Industrial IBM Model M 1395240-- NIB Cherry MX 5000 - IBM Model M 1391412 (Swiss QWERTZ) -- IBM Model M 1391403 (German QWERTZ) * 2 -- IBM Model M Ambra -- Black IBM Model M M13 -- IBM Model M 1391401 -- IBM Model M 139? ? ? *2 -- Dell AT102W -- Ergo (split) SmartBoard (white ALPS apparently)

Offline Findecanor

  • Posts: 5082
  • Location: Koriko
vim or emacs?
« Reply #14 on: Sat, 30 July 2011, 10:18:11 »
Neither emacs or vi(m).

Linux: pico (or GNU nano) for most things, actually. I use gedit for code when I don't have an IDE. My preferred IDE (right now) is Eclipse, and I like its editor.
Windows: Notepad++, but I wish it had a file pane, because that would make it easier to switch to a file.
🍉

vim or emacs?
« Reply #15 on: Sat, 30 July 2011, 10:35:00 »
Emacs for me. Especially for anything Lisp related (which is most of my code these days). SLIME is great.
Current collection: HHKB Pro 2 black on black, HHKB Pro 2 white/grey blank, [strike]Dell AT101W[/strike] (sold to SirClickAlot), 1992 Model M, Key Tronic Ergoforce KT 2001, BTC 5100 C. Dead boards: MS Natural Elite, MS Natural 4000.

Offline TacticalCoder

  • Posts: 526
vim or emacs?
« Reply #16 on: Sat, 30 July 2011, 11:11:08 »
Quote from: Superfluous Parentheses;389911
Especially for anything Lisp related (which is most of my code these days)


Lucky you.  Hence the great nick and the very cool lambda avatar...  I can see there are a few real coding gurus on GH ; )

Damn, I just did a search on your posts and realized YOU are the one with the very cool: "I use SUPER for all my window-manager key bindings, so they don't interfere with any standard bindings for applications." setup!

I want to replicate this!  I will make a post about this Real Soon Now [TM]  (I'm also using both Linux/Xorg and OS X)
HHKB Pro JP (daily driver) -- HHKB Pro 2 -- Industrial IBM Model M 1395240-- NIB Cherry MX 5000 - IBM Model M 1391412 (Swiss QWERTZ) -- IBM Model M 1391403 (German QWERTZ) * 2 -- IBM Model M Ambra -- Black IBM Model M M13 -- IBM Model M 1391401 -- IBM Model M 139? ? ? *2 -- Dell AT102W -- Ergo (split) SmartBoard (white ALPS apparently)

Offline czarek

  • Posts: 627
  • Location: Poland
  • Keep the momentum going!
    • FalbaTech
vim or emacs?
« Reply #17 on: Sat, 30 July 2011, 12:12:50 »
Quote from: TacticalCoder;389927
Damn, I just did a search on your posts and realized YOU are the one with the very cool: "I use SUPER for all my window-manager key bindings, so they don't interfere with any standard bindings for applications." setup!


You know that's why in good operating systems like Amiga and OS X you use Meta key for most actions because Control key is used in all terminal related things, and also all text boxes work with UNIX Control key shortcuts (like Ctrl+A to go to beginning line Ctrl+K to delete all to the end of line etc.).
Apple's recent politics is really **** but with OS X they made quite decent consumer grade desktop UNIX in beginning of this century.

And for those who would like to have Vi like text input throughout the system: http://www.macupdate.com/app/mac/22864/vi-input-manager
« Last Edit: Sat, 30 July 2011, 12:16:43 by czarek »
My little ErgoDox / GH60 factory: http://falbatech.pl

Offline TacticalCoder

  • Posts: 526
vim or emacs?
« Reply #18 on: Sat, 30 July 2011, 17:03:20 »
Quote from: czarek;389958
You know that's why in good operating systems like Amiga and OS X you use Meta key for most actions because Control key is used in all terminal related things, and also all text boxes work with UNIX Control key shortcuts (like Ctrl+A to go to beginning line Ctrl+K to delete all to the end of line etc.).

Yup I know, that's great and I use CTRL+A / CTRL+K all the time in my xterm etc.  It drives me mad when I'm using applications re-defining these shortcuts...
HHKB Pro JP (daily driver) -- HHKB Pro 2 -- Industrial IBM Model M 1395240-- NIB Cherry MX 5000 - IBM Model M 1391412 (Swiss QWERTZ) -- IBM Model M 1391403 (German QWERTZ) * 2 -- IBM Model M Ambra -- Black IBM Model M M13 -- IBM Model M 1391401 -- IBM Model M 139? ? ? *2 -- Dell AT102W -- Ergo (split) SmartBoard (white ALPS apparently)

Offline cactux

  • Posts: 918
  • Location: Australia
  • Topre Knight
vim or emacs?
« Reply #19 on: Sat, 30 July 2011, 17:16:58 »
vim shell and gvim gui
[FS]☠ The temple lol ->HERE<-

Offline lal

  • Posts: 360
vim or emacs?
« Reply #20 on: Sat, 30 July 2011, 17:19:55 »
vi for small edits when at the shell anyway.  Emacs for the big stuff.
BS: Customizer, Model Ms; Alps: CSK-2101, FK-2002, AT-101 (SGI & Dell), MCK-860, FKBN87Z/EB; Cherry: Poker X, FKBN87MC/EB, WY60, G80-3000, G84-4100, TDV 5010

Offline hashbaz

  • Grand Ancient One
  • * Moderator Emeritus
  • Thread Starter
  • Posts: 5057
  • Location: SF Bae Area
vim or emacs?
« Reply #21 on: Sun, 31 July 2011, 00:07:50 »
Quote from: TacticalCoder;389859
That's right: in less than 30 keystrokes all in all I did use some Lisp to add 1 to all the 70 values or so that needed it.  30 keystrokes and Lisp.  That's how powerful Emacs is.

That's impressive.  In vim I would record a macro utilizing the ctrl-A (increment) command, and apply it N times (86-30, or whatever).  Would probably come in at under 30 keystrokes.  But inline Lisp in a search-and-replace command is pretty freakin' cool, and way more general obviously.

One of the reasons I keep trying to learn emacs is because it really is the more powerful, robust environment.  But I just can't get over vim's modal editing model and command set, which are totally superior in my view (and viper mode isn't nearly good enough).

Offline czarek

  • Posts: 627
  • Location: Poland
  • Keep the momentum going!
    • FalbaTech
vim or emacs?
« Reply #22 on: Sun, 31 July 2011, 02:27:06 »
Quote from: hashbaz;390243
That's impressive.  In vim I would record a macro utilizing the ctrl-A (increment) command, and apply it N times (86-30, or whatever).  Would probably come in at under 30 keystrokes.  But inline Lisp in a search-and-replace command is pretty freakin' cool, and way more general obviously.

One of the reasons I keep trying to learn emacs is because it really is the more powerful, robust environment.  But I just can't get over vim's modal editing model and command set, which are totally superior in my view (and viper mode isn't nearly good enough).

Wrong mate - in Vi you do a regex to do that and it will take you much less keystrokes - here's simple example: http://www.xinotes.org/notes/note/41/
My little ErgoDox / GH60 factory: http://falbatech.pl

Offline xwhatsit

  • Posts: 297
  • Location: NZ
vim or emacs?
« Reply #23 on: Sun, 31 July 2011, 06:02:46 »
Vim.

For Eclipse, I use vwrapper (almost-vim, but integrated into the Eclipse/CDT editor pane).

Can't stand the Emacs meta-this ctrl-that style. Give me modal!
Beam spring IBM 5251 (7361073/7362149) & IBM 3727 (5641316) | Model F IBM 122-key terminal & IBM PC-AT 84-key | Model M Unicomp 122-key terminal | Cherry MX Blue Leopold Tenkeyless

Offline kps

  • Posts: 410
vim or emacs?
« Reply #24 on: Sun, 31 July 2011, 09:42:55 »
vi(m).

vi isn't really modal; it simply has functions with arguments.

Offline alaricljs

  • I be WOT'ing all day...
  • ** Moderator Emeritus
  • Posts: 3715
  • Location: NE US
vim or emacs?
« Reply #25 on: Sun, 31 July 2011, 10:51:54 »
If vi isn't really modal, then you don't understand what modal means.  When you are not in insert/replace mode then everything you type is going to vi to interpret.  That's the modality of vi.
Filco w/ Imsto thick PBT
Ducky 1087XM PCB+Plate, w/ Matias "Quiet Click" spring-swapped w/ XM Greens

Offline kps

  • Posts: 410
vim or emacs?
« Reply #26 on: Sun, 31 July 2011, 13:22:36 »
Quote from: alaricljs;390386
If vi isn't really modal, then you don't understand what modal means.  When you are not in insert/replace mode then everything you type is going to vi to interpret.  That's the modality of vi.


That's an unproductive way to think of it, unfortunately encouraged by the original documentation; it makes it seem like there's a bunch of different special cases like “insert mode” and “replace mode” and “change mode” and whatever-else-I've-forgotten mode. Really though vi is a very simple, consistent, language for operating on text —

  [count] command [motion] [text ESC]

It's substantially the same as TECO, with the addition of motion operands.

OK, ex mode and open mode (not present in vim) really are modes, but they're not what people are normally referring to when they describe vi as modal.

Offline The Solutor

  • Posts: 2262
vim or emacs?
« Reply #27 on: Sun, 31 July 2011, 13:35:45 »
BTW wikipedia mentioned both vi and emacs as examples of modal and/or using interface modes

Quote
vi - has one mode for inserting text, and a separate mode for entering commands. There is also an "ex" mode for issuing more complex commands (e.g. search and replace). Under normal circumstances, the editor automatically returns to the previous mode after a command has been issued; however, it is possible to permanently move into this mode using Shift-Q.

Emacs - has a special mode for issuing commands, which is entered by pressing the control key plus a letter key. This differs from vi in that the mode always ends as soon as the command is called, when the sequence of key presses that activates it is completed. Emacs also has many "major and minor" modes that change the available commands, and are automatically invoked based on file type to more easily edit files of that type. Modes are written in Emacs Lisp, and all modes may not be included with all versions.
The problem with quotes on the Internet is you never know if they are true  (Abraham Lincoln)

Offline Minskleip

  • Posts: 230
vim or emacs?
« Reply #28 on: Sun, 31 July 2011, 13:59:07 »
I like ed; what you get is what you get :lol:

Edith: anyone using Emacs with a remote lisp image on windows (lisp+swank on server, emacs+slime on windows)? Cygwin ssh doesn't work with Windows-emacs, so I have to use Cygwin-emacs for tramp to work.. disapointing.. Assuming I'm setting this all up, will I be able to complete filenames in the slime-repl contrib when using slime-tramp?
« Last Edit: Sun, 31 July 2011, 14:02:57 by Minskleip »
What\'s in the back of my car? A cdr lol

Split Tipro keyboard with R3 keycaps

Offline shmithers

  • Posts: 28
vim or emacs?
« Reply #29 on: Sun, 31 July 2011, 14:13:51 »

Offline keyboardlover

  • Posts: 4022
  • Hey Paul Walker, Click It or Ticket!
    • http://www.keyboardlover.com
vim or emacs?
« Reply #30 on: Sun, 31 July 2011, 14:16:39 »
Quote from: shmithers;390520
SciTE for me ;)
http://www.scintilla.org/SciTE.html

Haven't used that in a while but I do recall liking it for perl.

Offline kps

  • Posts: 410
vim or emacs?
« Reply #31 on: Sun, 31 July 2011, 16:37:40 »
Quote from: Minskleip;390511
I like ed; what you get is what you get

I used ed for 4 months once, and then ex for a couple more before they got full duplex working. It's good training for vi, since you learn to make good use of regular expressions.

[Edit] And there's a good reason ed doesn't prompt, or display substitution results by default: you don't notice when the system is not keeping up with your commands.
« Last Edit: Sun, 31 July 2011, 16:41:12 by kps »

Offline xwhatsit

  • Posts: 297
  • Location: NZ
vim or emacs?
« Reply #32 on: Sun, 31 July 2011, 19:23:37 »
Quote from: kps;390561
I used ed for 4 months once, and then ex for a couple more before they got full duplex working. It's good training for vi, since you learn to make good use of regular expressions.

[Edit] And there's a good reason ed doesn't prompt, or display substitution results by default: you don't notice when the system is not keeping up with your commands.

Quite right -- I used vi over a telnet session to a very slow (and far away) embedded box once. Vi was very handy because of the count commands and stuff like ct/cf etc., making it far better over a crap link and slow hardware than a so-called `normal' text editor. But even vi eventually got on my nerves, updating the screen when I least expected it. Ed seemed to fit much better. That couple of weeks using ed improved my vi chops to no end too, as you say.
Beam spring IBM 5251 (7361073/7362149) & IBM 3727 (5641316) | Model F IBM 122-key terminal & IBM PC-AT 84-key | Model M Unicomp 122-key terminal | Cherry MX Blue Leopold Tenkeyless

Offline vyshane

  • Posts: 136
vim or emacs?
« Reply #33 on: Sun, 31 July 2011, 22:51:11 »
Quote from: czarek;389958
And for those who would like to have Vi like text input throughout the system: http://www.macupdate.com/app/mac/22864/vi-input-manager


Unfortunately input managers have been deprecated.

Offline hashbaz

  • Grand Ancient One
  • * Moderator Emeritus
  • Thread Starter
  • Posts: 5057
  • Location: SF Bae Area
vim or emacs?
« Reply #34 on: Mon, 01 August 2011, 01:09:30 »
Quote from: czarek;390285
Wrong mate - in Vi you do a regex to do that and it will take you much less keystrokes


Nice, I didn't know vim could do that.  I wasn't stating what vim is and is not capable of, just what I would have done to accomplish the same thing.

Offline hashbaz

  • Grand Ancient One
  • * Moderator Emeritus
  • Thread Starter
  • Posts: 5057
  • Location: SF Bae Area
vim or emacs?
« Reply #35 on: Mon, 01 August 2011, 01:18:32 »
Quote from: kps;390363
vi isn't really modal; it simply has functions with arguments.


Gotta disagree.  Modes are states in which identical input will result in different output.  That's why dialogs that don't let you interact with the main application are called modal -- they take over input.  Maybe I'm missing a subtler aspect of what you're getting at, but vim is inarguably modal.  So is emacs, for that matter (as was pointed out by someone else).

The larger point is that vim's central normal/insert mode distinction makes it pretty unique among text editors.  Many hate it, but I have grown to love normal mode since it frees me from having to perform a chord for every non-text-insertion command.

Offline hashbaz

  • Grand Ancient One
  • * Moderator Emeritus
  • Thread Starter
  • Posts: 5057
  • Location: SF Bae Area
vim or emacs?
« Reply #36 on: Mon, 01 August 2011, 01:21:22 »
In case anyone hasn't seen this little nugget of joy yet:

[ Attachment Invalid Or Does Not Exist ] 22938[/ATTACH]

Offline Johannes

  • Posts: 74
vim or emacs?
« Reply #37 on: Mon, 01 August 2011, 02:10:14 »