Live data from Hacker News

Vim Anti-Patterns

sanctum.geek.nz

91–100 of 249 posts

Re: Vim Anti-Patterns

#91
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 -…

Someone else has found the wisdom of ijkl! :D

My setup uses "u" and "o" the same way you use "h" and ";". I also extended it so you can use modifiers on I and K to get page up/page down behavior, or to navigate between indentation levels.

Re: Vim Anti-Patterns

#92

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 switched to Spacemacs a few months ago and didn't look back since. Its basically Emacs+Vim+Steroids+More.

Just the leader key and layers alone are incredibly powerful concepts Spacemacs brings on top of Emacs/Vim :)

Re: Vim Anti-Patterns

#93
post #45
post #40

Earlier quoted context omitted.

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?

Speaking as someone with a similar setup, I've never had many issues with plugins assuming the use of hjkl. The only one I can think of offhand that has issues is indent-object.

The thing that really causes issues is my attempt to swap the roles of [ and {, using [] to jump between paragraphs and {} to do fancy function jumping. Vim plugins really don't like that...

Re: Vim Anti-Patterns

#94
post #18

Note that d2wi and c2w are not exactly equivalent: d2w will consume trailing whitespace after the second word, while c2w will not. FAFAIK, there is no exact equivalent of d2wi using c. I usually end up using c2aw, but that will also consume any word characters preceding the cursor (not a problem for me since I usually navigate using b and w).

> d2wi and c2w There is a nice chart on this page with a few more inferior/superior motion commands: http://vimcasts.org/episodes/modal-editing-undo-redo-and-rep... One problem I commonly see with most vim advice articles is they just have too many tips for the reader to consume at once. But if you just make sure to pick up at least one of the tips, you'll at least gain something.

Indeed. I try to come back to pages like this every few weeks, and to start training myself to use one more of the tips from it. Today it's * and # to go to the next/previous instance of the word under the cursor.

Re: Vim Anti-Patterns

#95
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.

I decided one year that I would force myself (a vi die-hard) to use emacs for everything for an entire year, to see if I ever got used to it. One thing that never stopped driving me crazy was that there's no efficient way to duplicate a line like yyp in vim. The closest I could ever get in emacs was ctrl+k k ctrl+y ctrl+y (that is, delete the line and then paste it back twice). Looking online for a solution leads me to believe that the only way to really effectively use emacs is to learn lisp and reprogram it yourself.

Re: Vim Anti-Patterns

#96

While these tips are good per se, in retrospect I don't think it's that a good idea to tie your muscle memory that much to a single piece of software. I'd say enjoy the cursor keys. Moving around in insert mode is ok too.

This is normally true, except that in order to be good at your job as a developer, you have to be good with your tools.

It helps that vim is installed by default in every modern OS.

Re: Vim Anti-Patterns

#97

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.

> I have no idea how people learn Vim

LOL, I felt the same way about emacs when I tried to force myself to use it. Interesting that you point out that "the scripting is awful" - my sense after a year of using emacs full time was that the _only_ way to use emacs is to learn to script/reprogram it. If you don't mind my asking - how _did_ you learn emacs? Were you a lisp programmer to start with? Or did you learn it in the context of emacs?

Re: Vim Anti-Patterns

#98

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 switched to Spacemacs a few months ago and didn't look back since. Its basically Emacs+Vim+Steroids+More. Just the leader key and layers alone are incredibly powerful concepts Spacemacs brings on top of Emacs/Vim :)

Did you switch to Spacemacs from Emacs or vim? I tried getting into Spacemacs from vim and found it quite overwhelming with all the config files and additional configuration that I had to do so instead I went for just Emacs + EVIL mode and built from there. I've gotten pretty used to Emacs and Elisp now, would it be worth it giving Spacemacs another shot?

Re: Vim Anti-Patterns

#99

I have a programmable keyboard, so I just map escape to be right above tab, where tilde usually is.

I recall reading somewhere that Stallman's keyboard had the CTRL key where the (totally useless) caps-lock key is on modern keyboards, and that's why he used CTRL+ combinations throughout emacs.
Post reply on HN