Live data from Hacker News

Vim Anti-Patterns

sanctum.geek.nz

41–50 of 249 posts

Re: Vim Anti-Patterns

#41
post #29

I was originally a die hard Emacs user, but I started to feel a bit of strain on the whole holding Ctrl+p, Ctrl+n etc. I was trying to find an editor/plugin that can reduce keystrokes or at least the strain. I ran across EVIL for Emacs which is just a Vim emulation and keybindings for Emacs users. Unfortunately I did not like it at first the entire hjkl felt awkward and all those modes - OMG. But after toying around…

I love vim but admittedly ctrl-backspace-backspace is just as fast as d2b and works in nearly any editor. The stuff i really like is stuff as dt. which will delete until the end of the sentence, ie until the period. Or di( which deletes everything inside the parenthesis.

Try Ctrl-w in insert mode it is similar to Ctrl-backspace. Also in normal mode try db. where '.' just repeats the last command 'db'. I find I'm never really using counts in vim but instead using the repeat command '.' since it provides better visual feedback.

Re: Vim Anti-Patterns

#42
post #32

So I have used ST3 for years now, and I realise that I'm slowly moving toward Vim. I started using Vim shortcuts in Chrome, and now I use Vintageous in ST3. Vintageous is good, but it is incomplete. It can't even do the first examples on this article (ctrl+f / ctrl+b) correctly. Thinking I should just bite the bullet. Would mean I could work on a server using Mosh + Tmux as well, which should be rather nice. What wou…

Note sure about a guide but I would start without any plugins at first. Otherwise you never learn what's vim and what's a plugin, and working on remote servers will be a pain. Also for a lot of plugins, there's a better way of doing things in native vim if you learn it properly.

What worked for me to bite the bullet at uni was making myself do an entire programming assignment in vim and not opening in any other editor. If you commit it doesn't take that long to learn. Keep a list of commands handy and learn a few new ones each day.

Re: Vim Anti-Patterns

#43
post #13
post #3

> "If you have to move more than a couple of lines, moving one line at a time by holding down j or k is inefficient." This very point is actually why I moved from Vim to Emacs years ago. After mastering Vim, I realized that Vim strongly encourages you to think a little too much about exactly how to get there or do that thing in the fewest keystrokes, and that it's incompatible with muscle memory. Even years later, I…

Honest question: How does Emacs help with this particular problem ? I feel like with every editor, it involves repeatedly hitting J, Ctrl+N or down arrow, which is inefficient. Do you have a way to get to a particular line that does not force you to think too much about how to get there ?

Of course we do: You can jump by searching for line contents with C-s, you can do an operation a certain number of times with M- , and do an operation four times with C-u , which chains, so you can do an operation 16 times with C-u C-u .

If you want to jump to a specific line number, you can use M-g M-g , or (because C-u also provides numerical arguments) C-u M-g M-g.

Finally, many motion commands set the mark, so you can use C-x C-x to return to where you were and select all text between your previous and current locations.

Oh, and if you want something even better, you can use C-` to jump to the location of compiler error if you use M-x compile, you can use ag.el or helm-ag for ag integration, Ace-Jump, which is similar to EasyMotion, built-in exuberant ctags integration (and a built-in ctags clone, etags), packages for cscope integration (if you're using C), and fiinally semantic, which provides a variety of parser-based tooling if it's supported by your language.

But you can also just use C-n, etc. and we won't judge you for it.

Re: Vim Anti-Patterns

#44

I was originally a die hard Emacs user, but I started to feel a bit of strain on the whole holding Ctrl+p, Ctrl+n etc. I was trying to find an editor/plugin that can reduce keystrokes or at least the strain. I ran across EVIL for Emacs which is just a Vim emulation and keybindings for Emacs users. Unfortunately I did not like it at first the entire hjkl felt awkward and all those modes - OMG. But after toying around…

I got some basic muscle memory in Vim, then tried for a long time to learn emacs. Now I've found spacemacs, and couldn't be happier (which uses EVIL mode under the hood). If you haven't tried it, you should check it out.

Re: Vim Anti-Patterns

#45
post #40

Earlier quoted context omitted.

I don't really disagree with your overall point, the arrows keys are not horrible, but I think for beginners removing all arrow keys is the best approach. I used vim for a while just relying on the arrow keys, and it wasn't until I disabled them completely that I really started to use vim. If I left them on in insert mode, I would have just ended up using them that way, just due to muscle memory. I'd also add that if…

I tried and failed to make myself use `hjkl` instead of the arrow keys. It was a perpetual hindrance to my brain that up (`k`) and down (`j`) did not spatially reinforce their functions. What ultimately worked was to map the triangle `ijkl` like you normally see `wasd` in games. i jkl i -- up k -- down j -- left l -- right I then added two more keys beyond left and right to skip forward and back by words. i hjkl; h -…

Oh god... doesn't this mess with plugins or something?

Re: Vim Anti-Patterns

#46
I started off using Emacs a lot (like tons and tons of Emacs with tons and tons of custom modes, functions, and craziness - network pong anybody?). For almost a summer, my xinitrc at the school labs literally opeed up a full screen Emacs; it was my window manager too.

The simplicity of vim (and pretty colors) drew me in. Plus as I learned more sed/ed, I understood vi more. That, and a slow connection from off campus really sucks. I learned that too pretty well. Well enough to hack together some vim scripts, but nothing near my Emacs level. I feel like vim mode hacking is a beast you need to be specially equipped to handle (and I can write APL in any language so it isn't the syntax).

Then Eclipse and IntelliJ came around and I only really used vim for quick one off stuff (if I didn't use printf, echo, or cat). The only time I used vim was for C/C++ or something esoteric, like KDB+/Q/K, that didn't have their own dev environment (unlike say VHDL or Matlab where I could sit in their ugly cocoons).

Now I'm growing tired of the very buggy, slow Java environments that seem to require a gaming rig to compile HelloWorld.java (or sorry, HelloWorld.xml with SpringBoot). And I see all these poor Emacs clones playing catchup with 2000. You have editors written in JavaScript inside a web browser with modules transpiled to JavaScript (for some reason JavaScript is too low-level to write text editing packages in now -- God help us all). That, and they don't support a tenth (I'm being generous) of the functionality that Emacs does and they probably never will.

What is so hard about an extensible text editor? Just getting the basic hooks down for self-insert and movement without having to go to swap?

I remember when Emacs was called "Eight Megabytes and Constantly Swapping". I now see Atom routinely take up over 800 MB. And it still can't play Pong.

Now with Rust and other languages, I'm back home in Emacs, but the keystrokes do tend to bother me a little. I liked the HJKL movement keys in vim - I just hated the modality and think I spent more time trying to figure out "my cursor is here, but I need move it over there - so first I need to jump on that log, shoot the rocket to knock down flowerpot then run quickly while the line is falling to catch it and K it to the next line" -- like some sort of weird text editing puzzle (I wonder if you could make a vim code golf puzzle set).

Emacs has these bindings that feel like finger yoga, even when I've remapped Caps, control, half my F-keys, etc. What I really need to do is remap my toes to my hands, I think.

It would have been really nice to see C-[hjkl] style movement (with maybe CS-[HJKL] be the distance mods or something). It's too late now. You of course you can remap those keys, but too much of that behavior is baked in to people).

Maybe one day when I'm old and gray I'll do the Knuth thing and start a new text editor, but before that I'll probably need to redo the monitor, mouse, and keyboard and that is just too much right now.

Re: Vim Anti-Patterns

#47
post #30

Earlier quoted context omitted.

Even easier to use the default Ctrl + [ instead of ESC.

I've somehow gotten in the habit of using ^C for Escape. Guess it feels natural from using it in Bash to restart typing my command or to kill a program.

Related: http://stackoverflow.com/questions/5030164/whats-the-differe...

Re: Vim Anti-Patterns

#48

Not trying to start a flame war here, but I in recent few years I am seeing Vim being more popular, and I feel it adoption in terms of younger developers (those who weren't programming when original Vi was around) grows. (Ok, please forget about GUI editors, they have their audience, and I am not comparing any of those facts to them) I used Vim for 3 years, and found philosophy and implementation of modal editing ama…

Emacs was far easier for me than Vim was. To this day, I have no idea how people learn Vim. And the scripting is awful, especially compared to Emacs, which is really a script interpreter that has a built in text-editor script and some useful primitives for text editing.

Re: Vim Anti-Patterns

#49
post #33

I was originally a die hard Emacs user, but I started to feel a bit of strain on the whole holding Ctrl+p, Ctrl+n etc. I was trying to find an editor/plugin that can reduce keystrokes or at least the strain. I ran across EVIL for Emacs which is just a Vim emulation and keybindings for Emacs users. Unfortunately I did not like it at first the entire hjkl felt awkward and all those modes - OMG. But after toying around…

> feel a bit of strain on the whole holding Ctrl+p others don't seem to like this, but i've found the following global key swaps effective swap ctrl->alt LCtrl::LAlt RCtrl::RAlt swap capslock->alt Capslock::Alt this enables you to hit "ctrl" with your thumb (next to the spacebar), and capslock becomes the new "alt". so no more reaching for that hard to reach LCtrl key with your pinky.

it's a tad bit weird but all the other command power you get from vim is just really comfortable. But I can see that swap working out in vanilla emacs

Re: Vim Anti-Patterns

#50

I started off using Emacs a lot (like tons and tons of Emacs with tons and tons of custom modes, functions, and craziness - network pong anybody?). For almost a summer, my xinitrc at the school labs literally opeed up a full screen Emacs; it was my window manager too. The simplicity of vim (and pretty colors) drew me in. Plus as I learned more sed/ed, I understood vi more. That, and a slow connection from off campus…

evil-mode

vim keys in emacs.

Post reply on HN