News for hackers. Stuff that matters.
Re:Bill Joy's greatest gift to man – the vi editor (2003) by coliveira on Wednesday May 06, 2020 @12:17PM (#23092754)
I used Emacs for 5 years before learning vi. What a change! While Emacs tries to put the kitchen sink inside the editor, vi tries simply to be a keyboard interface to the rest of the system. I've never looked back since I learned this way of working.
Re:Bill Joy's greatest gift to man – the vi editor (2003) by reddit_clone on Wednesday May 06, 2020 @04:05PM (#23095648)
Emacs user here. Emacs' real value is not really in text editing, though it is no slouch in text editing. It does so many other things so well, at this point it is unthinkable for me to not have it.

Eg. OrgMode, Magit, Helm, Tramp, Dired and slime to mention a few. Its a lifestyle ;-)

Re:Bill Joy's greatest gift to man – the vi editor (2003) by coliveira on Thursday May 07, 2020 @07:17PM (#23109512)
This confirms my point, people using Emacs are not interested in editing alone, but in a platform for elisp code. That's the reason I prefer vi.
Re:Bill Joy's greatest gift to man – the vi editor (2003) by nameless_me on Wednesday May 06, 2020 @05:42PM (#23096657)
Agree. Emacs is so much more than a text editor, it is more accurately described as a lifestyle. Operating systems are merely bootloaders for Emacs. ;D
Re:Bill Joy's greatest gift to man – the vi editor (2003) by umvi on Wednesday May 06, 2020 @12:19PM (#23092797)
I've tried several times to get into vim. I feel like it's similar to dvorak though - unless you use it 24/7 you won't develop the muscle memory necessary to use it efficiently.
Re:Bill Joy's greatest gift to man – the vi editor (2003) by KSS42 on Wednesday May 06, 2020 @12:31PM (#23093010)
Using it 12/7 was enough for me for me to be become proficient. ;)
Re:Bill Joy's greatest gift to man – the vi editor (2003) by ztoben on Wednesday May 06, 2020 @12:39PM (#23093119)
If it takes 84 hours a week of use in order to become proficient I think I'll pass.
Re:Bill Joy's greatest gift to man – the vi editor (2003) by kleer001 on Wednesday May 06, 2020 @01:42PM (#23093993)
Maybe 80 hours total, but then that's it. And then you have speedy skills that can serve you in almost any command line environment. AND vi commands are used in a lot of other places, like man pages and such.
Re:Bill Joy's greatest gift to man – the vi editor (2003) by gen220 on Wednesday May 06, 2020 @02:24PM (#23094547)
second the sibling comment.

it's an up-front cost, but it's one that you'll benefit a lot from over the years.

I recommend starting with soft plaintext, like a diary. Over time, you can migrate to using it to edit code. My conversion took a couple months, and followed this pattern.

I started by editing plaintext diary files. Then, once I was very use to the in-file navigation, I installed vim-mode on my editor of choice at the time, so I could benefit from efficiencies there, while keeping all the IDE benefits.

Then, I began the process of replicating all of the features I used in my IDE, in vim. that took maybe another month, and was motivated by how painfully un-snappy my IDE was relative to vim.

This is all to say, it doesn't have to be an all-or-nothing cutover. That would be painful and frustrating.

Re:Bill Joy's greatest gift to man – the vi editor (2003) by tombert on Wednesday May 06, 2020 @01:05PM (#23093501)
It honestly isn't nearly as difficult as learning Dvorak; you can be productive with Vim if you use it full-time for about a week. If you stay dedicated to learning and improving, you can get really good and become pretty productive.

While I love Vim and I use it most of the time, I don't really buy it when people act like it saved them a whole lot of time. I love the Vim keystrokes and philosophy, but I don't really know if I'm any more productive with Vim than I was with Emacs...I stick with Vim because I find that, once you "get it", it's relatively easy to translate stuff from your brain to the screen.

Re:Bill Joy's greatest gift to man – the vi editor (2003) by pikelet on Wednesday May 06, 2020 @02:56PM (#23094900)
I've always considered that it's more about comfort than productivity. And perhaps that comfort leads to a small increase in productivity, but more because you enjoy it than because it's so much faster to use (as we always say, we spend more time thinking that writing). And because so many tools use vi-style keybindings, if you spend any significant amount of time in a terminal, then you're going to experience that comfort and familiarity all the more.
Re:Bill Joy's greatest gift to man – the vi editor (2003) by tombert on Wednesday May 06, 2020 @03:38PM (#23095364)
Yep yep, completely agree.

I wish most of my time was spent writing code, but a vast majority is spent reading it and swearing at my monitor because things don't work, so I don't think even a perfect editor would make me a lot more productive, at least not directly, except (as you stated) maybe through me liking the editor a bit more.

I personally spend as much time as I can in the terminal, and so my "IDE" is actually is typically NeoVim, tmux, some kind of language-server, and a command line. Am I more productive than my peers using IntelliJ because of this setup? Almost certainly not, but I find it very intuitive for me to do stuff with, since I'm super familiar with the tmux keystrokes, and I find Vim's design really intuitive for me.

Re:Bill Joy's greatest gift to man – the vi editor (2003) by coliveira on Wednesday May 06, 2020 @12:40PM (#23093141)
You don't need to go hard core all at once. Start learning a few commands, such as "i", "a", "x", ":w", then add progressively more to your repertoire.
Re:Bill Joy's greatest gift to man – the vi editor (2003) by wcpines on Wednesday May 06, 2020 @01:15PM (#23093646)
Oddly enough, learning Dvorak during a [slow] summer internship and then learning to use Vim regexes to edit/search a couple TCP dumps at my first job probably are the reasons I eventually became interested in scripting/programming and eventually a software developer.

Really if it weren't for the first challenge of learning Vim, I wouldn't have learned to program. Which, I know, sounds kind of backwards :P

Re:Bill Joy's greatest gift to man – the vi editor (2003) by skohan on Wednesday May 06, 2020 @12:29PM (#23092979)
> simply to be a keyboard interface to the rest of the system

Can you expand more on what you mean by that? It's never really clicked with me what the exact value prop of vim is.

Re:Bill Joy's greatest gift to man – the vi editor (2003) by lgessler on Wednesday May 06, 2020 @12:39PM (#23093131)
Do you remember the time when every time you wanted to copy or paste something in a word processor you would dutifully hike your mouse up to the Edit button so you could select "Copy" or "Paste", and how when you learned that CTRL+C and CTRL+V was a thing your mind was blown with how much quicker it was? Vim gives you that experience, except times a gajillion because it not only speeds up what you already do in a WYSIWYG word processor but also gives you powerful new tools to edit that have no WYSIWYG equivalent.
Re:Bill Joy's greatest gift to man – the vi editor (2003) by skohan on Wednesday May 06, 2020 @01:07PM (#23093527)
> powerful new tools to edit that have no WYSIWYG equivalent

Can you give an example? I have heard this but I have difficulty understanding exactly what I could do in Vim that I couldn't do in Sublime Text for example

Re:Bill Joy's greatest gift to man – the vi editor (2003) by twh270 on Wednesday May 06, 2020 @03:37PM (#23095350)
It's not that you "can't" do certain things in Sublime. But Sublime and other "normal" editors have only a few primitives in terms of editing and moving, whereas vim has a language that lets you compose more complex commands from a set of primitives.

The general form of a vim command is:

(repeat)(verb)(motion/object)

That is, I want to perform 'verb' 'repeat' times on a 'motion' or 'object'. Examples:

  fX == 'f'ind the next occurrence of character 'X'
  3fX == repeat 'fX' 3 times
  w == go to the next word on the line
  3w == repeat 'w' 3 times, i.e. go 3 words right
  dw == delete word
  3dw == delete 3 words
  dfs == delete to the next occurrence of 's'
  yw == "yank" (copy to the buffer) the next word
  y3w == yank the next 3 words to the buffer
  H, M, L == move the cursor to the top, middle, or bottom of the screen
  zz == center the current line of text in the editor window.
  8j == move the cursor 8 lines down
  ma == create a bookmark 'a'
  `a == go to bookmark 'a'
  "ay == yank to buffer 'a'
  "ap == paste buffer 'a'
  . == repeat the last editing command (insert, delete, yank...)
I like vim because its commands are both efficient and precise. I don't need to look and make sure the cursor is at the right position or that I've selected what I want to cut/copy correctly. I know it's correct because I typed it in. And I don't need to move my hand to the mouse or arrow keys. And bookmarks and buffers are great.
Re:Bill Joy's greatest gift to man – the vi editor (2003) by __s on Wednesday May 06, 2020 @01:28PM (#23093813)
Does Sublime support macros? Macros are particularly useful when fixing up semi structured text (like converting a CSV into SQL)

Even then, macros kind of have to be keyboard based, as the keyboard presents a straight forward serialization format. Similar to how macros in non-Lisp languages struggle to achieve an elegance you can't quite capture unless your language is literally a textual AST

But there's also the random things because there's so much. Like ~ to swap case, or Ctrl-A/O for increment/decrement. I find myself in non-vim editors typing "dd" all too often

Re:Bill Joy's greatest gift to man – the vi editor (2003) by ur-whale on Wednesday May 06, 2020 @02:38PM (#23094693)
3

Shift+y

3

j

p

3

>>

time yourself doing the same thing in sublime.

Re:Bill Joy's greatest gift to man – the vi editor (2003) by coliveira on Wednesday May 06, 2020 @12:38PM (#23093106)
Vim gives a consistent and quick interface to editing operations based on a set of standard keys with modifiers. But it doesn't try to be everything to everyone. "plugins" for vi, at least in the classic sense, tend to be minimal. The editor relies more on integration with the UNIX ecosystem. This makes vi unlimited in its possibilities, without having to rely on thousands of lines of lisp code, like emacs does.
Re:Bill Joy's greatest gift to man – the vi editor (2003) by throwaway_pdp09 on Wednesday May 06, 2020 @12:48PM (#23093271)
> rely on thousands of lines of lisp code, like emacs does

Millions actually.

I'm an emacs user (who does not want to get into an editor war, mmkay). The plugins are so useful. I'm just learning magit and it very much takes most of the evil and hostility out of Git and I really like it. I also have dired (a sophisticated directory editor), and about to learn loads more such as Bookmark+ which allows links and jumps to anything you set, and allows you to save your desktop layout and files.

Emacs has so much, if only you can find it (align-regexp is very useful but there is so much more). Edit: look up M-x occurs if you haven't met it. Mega useful.

Consistency is going to be lost as you add functionality. If Vim doesn't have that problem it will in time.

Emacs isn't perfect, the package library melpa has dubious quality software, but emacs really is very good indeed.

Re:Bill Joy's greatest gift to man – the vi editor (2003) by coliveira on Wednesday May 06, 2020 @12:58PM (#23093408)
That's correct, Emacs is a platform to write applications that can connect to a text editor. This is a different proposition than vi. Like other unix tools, vi goal is to concentrate on one thing (editing), and let the rest, like email reading, git operations, etc., to be handled by other UNIX tools.
Re:Bill Joy's greatest gift to man – the vi editor (2003) by throwaway_pdp09 on Wednesday May 06, 2020 @01:09PM (#23093561)
I think you misunderstand. Though I've not set up email myself, I believe most email tools export their actual operations to an external tool (gnus may be an excpetion, not sure). I know for a fact that magit, the git interface, delegates directly to git. For source file tags and tag searching it delegates to an external tagger.

I don't think it does as much as you might think.

Re:Bill Joy's greatest gift to man – the vi editor (2003) by pmoriarty on Wednesday May 06, 2020 @02:03PM (#23094281)
I used vi and vim for about 25 years before switching to Emacs.

I did this because:

1 - I got deeply interested in Lisp and Scheme, and Emacs was reputed to have the best editing environment for these languages

2 - Almost all of Emacs itself and Emacs' entire package ecosystem is written in eLisp, which is a tremendous improvement over vimscript, in which almost all vim packages are written. I'd just rather read and write eLisp over vimscript any day.[1]

3 - Emacs offers so much more than vim (or neovim). You read and write your email in Emacs, surf the web in Emacs, chat on IRC in Emacs, have deep shell integration in Emacs[2], read RSS news in Emacs, use org-mode (which vim only has pale imitations of) and do just about everything else you'd ever want in it, which is not really the goal of vim, and certainly the opposite of the minimalism of vi.

4 - Emacs had packages that would emulate vim (evil-mode being by far the best and most complete of them all), which would allow me to bring my decades of vim knowledge and plugins over to Emacs, so I'd feel right at home.

The switch was a success, and I've been using Emacs for about 10 years now. I have no reason to go back, as Emacs does virtually everything vim does and much more than vim doesn't.

There are still a few things I miss from vim, and I still fire it up on systems where Emacs is not installed and where I don't have my Emacs config (I don't like using Emacs' TRAMP mode, for reasons I won't go in to here), and for a few tasks where Emacs just isn't adequate.

For instance for editing files with really long lines or gigantic files which Emacs just chokes on.[3] vim's regex engine also has some features Emacs lacks (ie. vim's \zs and \ze zero-width patterns are ones I sorely miss in Emacs).

Otherwise, though, evil is a pretty feature-complete emulation of vim, and I don't find myself missing the latter much.

It did take me a really, really long time to get my Emacs configured to be the way I liked it, though.. and that's a never-ending process.

So I wouldn't necessarily recommend that other vim veterans switch to Emacs unless they've got a huge amount of time on their hands, love tinkering with their configs, and either already love or are open to learning to love Lisp. I happen to be one of those people, so it's worked well for me.

[1] - Yes, it's possible to write vim packages in Guile Scheme, but virtually no one does this. A Guile Scheme ecosystem doesn't exist for vim, so if I chose to write Guilde Scheme packages for vim, I'd pretty much be the only one doing it. Not so in Emacs, where everyone writes packages in eLisp.

[2] - Emacs' shell integration didn't turn out as great as I expected, as it's vulnerable to Emacs' atrocious handling of long lines, slowness, and buggyness of its shell modes (though libvterm is supposed to offer a real shell inside Emacs, which is reputed to be a lot better than other shell modes written in eLisp, but I haven't tried it).

[3] - vim also isn't great at files with super long lines and gigantic files, but it's better than Emacs.

Re:Bill Joy's greatest gift to man – the vi editor (2003) by yjftsjthsd-h on Wednesday May 06, 2020 @02:50PM (#23094838)
> I used vi and vim for about 25 years before switching to Emacs.

Then maybe you can help:) I've tried, multiple times, to switch to emacs. And every time, I get stuck, because vim keybindings are so wired in to my muscle memory now, and even the broader interactions are hard to adopt (i.e., I expect to get a command prompt by escaping to command mode and then typing ":", and then all commands are available). Is there any trick that you found helpful to overcome all the inertia?

Re:Bill Joy's greatest gift to man – the vi editor (2003) by wadkar on Wednesday May 06, 2020 @03:25PM (#23095199)
Try something like spacemacs[1] maybe and use it only for one specific task like org-mode[2]. That way, vim is still your daily driver, but you get to play with lisp/emacs on something very cool like org-mode!

Then, you can slowly try to switch one thing at a time, for example start editing all Dockerfiles in spacemacs, or maybe do that one hello-world project/app in clojure/phoenix using spacemacs. See how you like it, tweak it a bit.

Finally, decide on using it as a daily driver for a new project and stick with it. It will grow on you.

[1] https://www.spacemacs.org/ [2] https://orgmode.org/

Re:Bill Joy's greatest gift to man – the vi editor (2003) by yjftsjthsd-h on Wednesday May 06, 2020 @03:59PM (#23095599)
Oh, that's a good idea:) And org-mode is compelling enough to entice me in... Thanks, I think I'll try that:)
Re:Bill Joy's greatest gift to man – the vi editor (2003) by ralls_ebfe on Thursday May 07, 2020 @03:37AM (#23100663)
I got into emacs because of org-mode. Transitioned from vim to spacemacs with evil-mode. Can recommend. :)
Re:Bill Joy's greatest gift to man – the vi editor (2003) by pmoriarty on Wednesday May 06, 2020 @03:16PM (#23095124)
I'd recommend using evil-mode. It'll give you the stock vim keystrokes and the command prompt (ie. what you get when you press the : key).

I was tempted to say "just use evil-mode", but it's really not "just" a matter of using it. evil-mode doesn't get you everything, as many Emacs modes just don't have vim-like bindings, and you'll either need to rebind them all yourself to something that makes sense for you (which is what I did, and I recommend creating lots of hydras to help you remember everything that's available), or you can use something like Spacemacs or Doom which will set up sane defaults for a lot of modes.

I've never used Spacemacs or Doom myself, but I've heard good things about both.. and bad things about Spacemacs, and how Doom is supposed to be an improvement on Spacemacs.. but as I've not used either I can't really comment on how accurate those claims are. I'd suggest doing your own research on those, or maybe someone here can comment on them.

Also, I'd recommend joining #evil-mode on the Frenode IRC network, the Emacs subreddit, and the Emacs StackExchange. You can get all of your questions answered there, and learn a ton about Emacs by reading these.

Re:Bill Joy's greatest gift to man – the vi editor (2003) by yjftsjthsd-h on Wednesday May 06, 2020 @03:22PM (#23095177)
Yeah, IIRC I've tried Spacemacs and Doom... I think I managed to hit things that they didn't implement... oh, I know: I've gotten the (bad?) habit of going to normal mode by hitting ctrl-c rather than escape, and I think evil didn't handle that. (To be fair: It works in (neo)vim, but ctrl-c to get to normal mode doesn't work nicely in other vi versions either, which is why I suspect it's a bad habit and/or me abusing some misfeature that wasn't intended to be used that way.)

Perhaps I should take another swing at it and see if I can't deal with the quirks...

Re:Bill Joy's greatest gift to man – the vi editor (2003) by elteto on Wednesday May 06, 2020 @03:14PM (#23095086)
You must have heard of evil by now... but if not check it out. It's a vim emulation layer for Emacs.
Re:Bill Joy's greatest gift to man – the vi editor (2003) by yjftsjthsd-h on Wednesday May 06, 2020 @10:21PM (#23098988)
Yeah, I tried evil (and variants that used it), but the slight edge cases where it didn't quite work like vim messed me up enough to undermine its usefulness. Both in that I actually used things that it didn't provide, and in that hitting some places where it didn't work cast uncertainty over the whole thing: In vim, if I know a keybinding or command, it will work; in evil there was always a moment of "will that work... okay, that does work" that broke my flow (or worse, "okay, let me just... oh, evil doesn't do that, now what?").
Re:Bill Joy's greatest gift to man – the vi editor (2003) by pmoriarty on Wednesday May 06, 2020 @11:55PM (#23099549)
With the exception of certain corner cases, when evil-mode doesn't exactly emulate vim it's considered a bug and should be reported as such.

I have run in to some of those corner cases myself, and had to ask myself whether they were worth giving up Emacs and evil for, and the answer for me that was that they weren't. Both are way too useful for me, and an occasional hiccup here and there isn't worth giving them up and going back to vim.

Also, I don't run in to those corner cases very often. Maybe 95% percent or more of the vim commands and features I use myself are completely emulated by evil without issues.

One other thing to ask yourself when running in to such cases is whether they're really an incompleteness in evil's vim emulation or maybe just a lack of a keybinding or some function that you could easily write yourself (if you know eLisp).

It's taken some elbow grease, but I've ironed out a lot of the wrinkles such as missing vim-like keybindings in modes that don't come with them by default (others use spacemacs or doom for this).

Re:Bill Joy's greatest gift to man – the vi editor (2003) by DonHopkins on Wednesday May 06, 2020 @02:29PM (#23094605)
>4) Emacs had packages that would emulate vim

It's terribly inefficient for emacs vi emulation mode to actually quit emacs when you type ":q", because it takes much longer for emacs to start up than vi, and people use a long-running emacs a lot differently than they use disposable vi's.

UniPress Emacs's vi emulation mode would actually flip you over to an emacs shell buffer when you typed :q, and the shell would recognize when you typed "vi foo.c" and flip back over to a vi emulator buffer instead of actually running vi, but INSTANTLY, since changing buffers in a running emacs was much faster than actually starting up a new vi process.

So die-hard vi users didn't have to re-learn their muscle memory, and could just stay in the same emacs all the time, while the same old emacs alternately flipped between pretending to be a shell, and pretending to be vi.

Re:Bill Joy's greatest gift to man – the vi editor (2003) by pmoriarty on Wednesday May 06, 2020 @03:25PM (#23095196)
"it takes much longer for emacs to start up than vi"

This is false on pretty much any modern system. They start up in about the same amount of time. Using lots of packages (in both vim and Emacs) will slow down startup speed, but there are tricks to speed that up too (like by defering actual loading of them until they're needed).

Also, most people who run Emacs just keep it running all the time, and almost never quit or restart it, so startup speed would not be an issue even if it was slow, which it isn't.

"people use a long-running emacs a lot differently than they use disposable vi's"

Emacs has an emacs-client binary which you can use exactly the way you use a disposable vi (or vim). It'll connect to the long-running Emacs process in the background, but that's an implementation detail that you as an Emacs user wouldn't have to worry about, apart from starting Emacs once when you boot your system.

Regarding your description of shell-flipping, Emacs does offer shell integration, where that sort of thing can be done, but I personally don't use it and run shells outside of Emacs (and run both my shells and Emacs itself under tmux), so my workflow with Emacs and the shell mirrors the traditional vi/vim workflow.

I didn't have to change my decades-old vim muscle memory or workflow when I made the switch to Emacs.

Re:Bill Joy's greatest gift to man – the vi editor (2003) by DonHopkins on Wednesday May 06, 2020 @06:51PM (#23097351)
It was true of UniPress Emacs, running on a 4 meg Sun 3/50. It's been a long time since UniPress sold any version of Emacs.
Re:Bill Joy's greatest gift to man – the vi editor (2003) by alexhutcheson on Wednesday May 06, 2020 @04:48PM (#23096110)

    alias vi='emacsclient -t -a ""'
Then whenever you run 'vi' it will create a new frame on an Emacs instance that's running as a server[1]. If there's not an Emacs server already running, then it will start one for you, so the first invocation will be slow, but every subsequent invocation will be fast. No need to change your muscle memory for this particular case.

[1] https://www.gnu.org/software/emacs/manual/html_node/emacs/Em...

Re:Bill Joy's greatest gift to man – the vi editor (2003) by DonHopkins on Wednesday May 06, 2020 @02:27PM (#23094569)
Also: Emacs has shell windows, process management, and output filtering, and keyboard macros, so it can run and control and respond to sub-processes (kind of like "expect" on steroids).

I could not give up running shells in an emacs shell window, capturing all the output as normal text I can edit and search with the full power of emacs, instead of a dumb scrolling terminal emulator, and the ability to make keyboard macros that hop between text files and dired directory listings and shell windows, copying file names and data to fire off sequences of shell commands. Easy on-the-fly automation of repetitive tasks. Why write a single use shell script when you can just do it once by hand while recording a keyboard macro, then repeat it thousands of times.

Re:Bill Joy's greatest gift to man – the vi editor (2003) by pmoriarty on Wednesday May 06, 2020 @03:27PM (#23095225)
So what do you do when some shell command you run chooses to spit out a bunch of really long lines?

Emacs would freeze on me when this happens.

Is there a way around this apart from running a shell under libvterm? Or is this even still an issue under libvterm too?

Re:Bill Joy's greatest gift to man – the vi editor (2003) by alexhutcheson on Wednesday May 06, 2020 @04:52PM (#23096148)
Not OP, but that hasn't come up for me very often. If a command output is really long or takes a long time to run I'll normally run it using M-& (async-shell-command) instead of running it in a shell buffer.

Long lines are a more general issue with Emacs, but there's changes in Emacs 27 that should mostly solve it.

Re:Bill Joy's greatest gift to man – the vi editor (2003) by pmoriarty on Wednesday May 06, 2020 @05:13PM (#23096365)
"that hasn't come up for me very often"

The fact that it can happen and does happen leads me to avoid Emacs' shell modes altogether. I just don't want my Emacs freezing on me ever. Considering how much I do in it, it freezing on me is an utter and complete disaster that I want to completely avoid even if it doesn't happen often.

"there's changes in Emacs 27 that should mostly solve it"

If you're talking about the solong mode integration, that's just a hack that kind of works for static buffers, but won't help in dynamic buffers like shell-mode.

To really and truly fix this issue, a core part of Emacs will have to be rewritten, and since that part is written in C and is pretty hairy, no one seems to want to deal with it. So it probably won't happen any time soon.

I'm just hoping Emacs' libvterm integration provides a good workaround, at least for using a shell from within Emacs. I'll have to give it a try one of these days.