Live data from Hacker News

Why I can’t stop using Vim

kornerstoane.com

81–90 of 169 posts

Re: Why I can’t stop using Vim

#81
post #17

Earlier quoted context omitted.

I think you're using the editor's modality wrong. ESC is not used to exit from Insert mode. ESC is used to switch from any mode back to Command mode. In fact Command mode is also called Normal mode. You should spend 95% of your time in Normal mode and use the other modes when you need them. I suggest binding `kj` to ESC since it allows you to quickly make a change and continue browsing your code. Take the following s…

Interesting coincidence, I was pasting a production certificate into Vim the other day and it contained "kj", which escaped the editor and ate a few letters until it reached an "i" and continued pasting. It took production down for 30 minutes until I noticed it. Remember, kids! ":set paste".

I usually use `paste` but I sometimes catch myself formatting just-pasted chunks of code. I'll watch out for this.

Re: Why I can’t stop using Vim

#82
Yay, I'm glad J got a shout-out even if it is one of the rejected editors. I've loved using J in the past and have even made a few releases of J on sourceforge [0]. I've attempted to move to github as well [1]. Sadly, I haven't found much time to work on it -- paid work and family take precedence. Oh, and I too love using vim as well.

  [0] http://armedbear-j.sourceforge.net/
  [1] https://github.com/kevinkrouse/j/tree/master/j

Re: Why I can’t stop using Vim

#83
post #72

I spent this entire weekend setting up Evil mode for Emacs, in the Emacs Starter Kit package. It's been decent so far. Evil mode is surprisingly good, and I really don't think it could come any closer to vim emulation for Emacs. Took a lot of googling around to set up some basic plugins that I need - projectile for CtrlP etc. I think the only thing that I need atm is Magit integration with Evil and I'll be good to go…

Do you happen to have some resources you can share? I've been playing with Tidal, a live-coding library and it wants me to use Emacs, and I just... can't. So any info on setting up evil-mode would be great, especially since it's fresh in your mind. I've found some resources but really don't know where to start.

I haven't dived into the details of Evil mode too much. The basic Vim motions and commands work out of the box, so for a casual vim user, it ought to be enough. I also went ahead and installed Evil-leader, so I could have the same keymaps that I have in my vim config.

A few places where I looked for small things here and there:

1. http://www.emacswiki.org/emacs/Evil

2. https://github.com/cofi/evil-leader

3. https://stackoverflow.com/questions/8483182/evil-mode-best-p...

4. https://github.com/mixandgo/emacs.d/blob/master/my-evil.el

5. https://bling.github.io/blog/2013/10/27/emacs-as-my-leader-v...

And I also got ido-vertical-mode so the emacs command buffer looks better.

Here's my setup: https://github.com/mgill25/emacs See user.el

Cheers!

PS: Some of the configuration needs to be set up before you activate certain modes - which is often implicit in plugins, so watch out for that. Eg: To emulate C-u behavior, the functions had to be put ahead of the (require 'evil) call in evil-leader.el

Re: Why I can’t stop using Vim

#84

Earlier quoted context omitted.

> Same with "1G to go to the top of the file, G to go to the bottom" - esc-1-shift-g vs ctrl-home. Same with ctrl-end. gg beats both (I don't think I've ever used 1G to jump to the top of the file)

I was taught that one by the brother-in-law. He also tried to teach me 1234l (the letter 'l') to go to the end of a line. I figured out a better way pretty quickly on that one. I didn't find the magical 'g' until much later, and 1G was already burned into my synapses. I'm trying to change. It's a little awkward :)

That's actually kind of an interesting idea. $ for end-of-line always bugs me; for something so common I don't think it should require a chord. '999l' is pretty easy to tap out.

On the other hand, it would probably be easier to rebind something like '-' as end-of-line. I'd do backspace, but I've already changed that to PageUp (backspace/space work great as PageUp/PageDown)

Re: Why I can’t stop using Vim

#85
post #8

Earlier quoted context omitted.

I don't really agree about "esc". "Normal mode" is the normal mode as the name indicates. That's where you normally start from. It's the actual writing that's two characters more (start insert mode, write, exit). Unless you're just writing new file from scratch in one go, you're likely to be in normal mode a lot of the time. Also, shift is not needed for the beginning of the file. It's also "gg" for the first line /…

"It's the actual writing that's two characters more (start insert mode, write, exit)." Makes sense. Asking for permission to type in a text editor feels counter-intuitive, but I'll give that a try.

This goes better when you know (and have internalized) more of the paths into insert mode.

For instance, ci} will delete everything inside the tightest enclosing braces and switch you to insert mode. This whole thing, then, including what you type, is a single action that you can redo with .

Re: Why I can’t stop using Vim

#86

>q to record a macro; @ to execute it again Is using macros' really common? I haven't yet figured out in when and where to use macros during my workflow.

Thank you for asking that.

I have been wondering the same thing for some time. I always hear how great macros are, but haven't actually found a real world use case in my work.

But I figured it was because I didn't know something.

Re: Why I can’t stop using Vim

#87
post #74
post #69

Earlier quoted context omitted.

I'm not a seasoned user or anything, but I prefer to use Emacs with a GUI rather than in the terminal. It has nothing do with there being more GUI-type things in there - I have things like save-icons etc. turned off. It just feels more like it's own application in GUI mode (if I run it in terminal mode, the Meta hotkey doesn't work as usual, which I suspect is because the terminal is using the alt-key (meta) for some…

The only advantage I know for using emacs in terminal is that you can get used to it when you'll have to ssh into a remote server. Anyway today we can just sshfs and use even a random ide for everything so... we can do as we like.

In my experience, any sort of filesystem remoting a la sshfs simply doesn't perform well enough to do real editing work in. One of the really nice things about vi is that it was originally designed for low-bandwidth situations, so using it over ssh is quite snappy even on a marginal network. If I had to use sshfs from home to edit files on my production servers I would probably have to kill myself.

Re: Why I can’t stop using Vim

#88
post #20

First you'll learn how to orientate around text quickly using normal mode, then you'll start playing with tabs, splits and buffers to search between multiple files, and then you'll start using registers to save phrases and regular expressions to search directories. At that point you'll never want to leave Vim again. :wq

:x (It's the same as :wq, but one character shorter.)

No it is not the same. x only writes if not already written.

Re: Why I can’t stop using Vim

#89

>q to record a macro; @ to execute it again Is using macros' really common? I haven't yet figured out in when and where to use macros during my workflow.

I use Vim on structured, tabular data quite a bit (think CSVs/TSVs/large HTML tables/etc.). Macros are handy for handling complex operations on rows like "skip the first two fields; delete this column; add this new column; make everything in this column uppercase; delete the rest". Just start recording, edit the first row and apply it to every other line when you're finished.

Re: Why I can’t stop using Vim

#90

>q to record a macro; @ to execute it again Is using macros' really common? I haven't yet figured out in when and where to use macros during my workflow.

I do a lot of work on multiple rows/sections/blocks of similar data. My workflow usually goes like this... 1. Do the same thing 3 times, realize that I'll be done faster if I automate it. 2. qz to record a macro into buffer z. 3. Do the work, taking care to leave myself in a state where the next invocation of the macro will pick up right where I want it to. 4. q to finish recording. 5. :map @z to execute buffer z 6.…

20@z repeats your macro 20times.
Post reply on HN