Live data from Hacker News

Vim Anti-Patterns

sanctum.geek.nz

221–230 of 249 posts

Re: Vim Anti-Patterns

#221
post #87

Instead of c2w I prefer v2ec selecting with v helps me avoid making mistakes.

ct" or even ci" (or ci) ci] etc) is really useful to reset the inner contents of text delimited by ")] etc.. I use these a lot - http://fuckyeahvim.tumblr.com/image/122372862496

ci", ci), ci]... I love these, and use them all the time.

Re: Vim Anti-Patterns

#222
post #162

Earlier quoted context omitted.

My favorite "secret" vim feature, that no one has mentioned yet: set scrolloff=999 That will keep the cursor in the middle of the window always, except at the start and end of the file. Before discovering that I used to `zz` after nearly every movement; that's all gone now, saving a ton of time and frustration.

I would go nuts; I prefer to use the whole screen to see what I'm looking at, and if I've just searched a buffer for a function name or whatever, there's a good chance I want to see the whole function and not the (screen height / 2) lines above it. (In emacs this is done with `C-l C-l`, in vim it's `zt`) While scanning a buffer for some pattern I'll quite often make a one-off keyboard macro that searches for a patter…

Oh guys, thank you so much for new food for my vim-addiction. I'd hesitate to call myself anything but an interested beginner, so it's always very welcome to learn new stuff. I distinctly remember running vimtutor the first time as a teenager fresh of whatever Windows came before and thinking 'goddamn, whyyyyyy is this hot mess so popular among my mentors and idols?'...

Quite some years later, I don't think I could ever do without vim. Not saying that emacs wouldn't probably fill the same role, editor wars considered and all. I just had somebody tell me to pick an editor and get good with it, some blog or forum posting made me go with vim and it's been one of my favorite pieces of software since.

To contribute a little bit, what I've really come to learn recently is the 'hybrid line numbering mode' that was added with 7.4 iirc. When you add both. set relativenumber

set number

to your .vimrc, you get relative numbers for all lines except the current, which is displayed as absolute. Helped my navigation game a huge deal. Just in the unlikely case anyone here hadn't heard of it.

Re: Vim Anti-Patterns

#223
My favorite is mapping '()' to 'vi)', '[]' to 'vi]', '{}' to 'vi}'. So I can read is as "grab parentheses" instead of "visual inside parentheses"

Re: Vim Anti-Patterns

#224

Earlier quoted context omitted.

...Which is actually quite simple. Here's my function for doing that that I wrote just now: (defun duplicate-line (interactive) (kill-whole-line) (yank) (yank)) Five lines, and it took me all of ten minutes to write, including looking up the names of all the functions. Of course, there's probably a better way to do this, but I don't know what it is. Now all you have to do is bind it to a key. Or, of course, you could…

I have mine set up like this: https://gist.github.com/asummers/7784d40b1bc53ee309777274e9d... That way I can hit M-w when I don't have a region and get the copy behavior for the whole line.

That's cool. I have no idea how that works, but it's cool.

Re: Vim Anti-Patterns

#225
post #208
post #207

While it's unarguably fun, I can't believe the effort required to become actually good at vim (as opposed to just using a few of the easier features) will ever pay itself off. (These days, at least - if you spend your days editing code in a terminal over a dialup connection, then it's absolutely worth it!) Maybe there are scenarios where the busywork of text editing really is on your critical path, but even as a flue…

Did you take the time to learn vim? Just start using it. With only a small subset of commands you can be pretty damn efficient. The fact that you can compose actions means that you don't need to remember every command - you can just create them yourself. After a very short while you will "get" it. You can say to yourself "I want to change the next three words" and immediately do it by pressing "c3w". Or you can move…

Oh, I've been using it for years and I'd consider myself an adequate vim user. I'm quite comfortable in it, just using the basics - but given the small amount of time I spend using it these days, the added investment to learn the more seems redundant.

Re: Vim Anti-Patterns

#226
post #9
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…

As an Emacs user I want to plug ace-jump-mode to move around the viewable part of the buffer more efficiently than many of the commands mentioned in the OP's post. 1. look at character you want to go to 2. M-x ace-jump-mode (I have this bound to F9) 3. Hit key for the character you want to go to 4. All instances of them are rewritten in the buffer with a coloured character. 5. Hit the coloured character you are looki…

This reminds me of easymotion.

Re: Vim Anti-Patterns

#227

Earlier quoted context omitted.

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?

I switched from Emacs, had already read https://gist.github.com/nifl/1178878 a few months prior which got me REALLY curious about Vim. I was using Emacs Prelude before and spent vast amounts of time customising my Emacs.

Then coworkers suggested spacemacs after I talked about an Emacs/Vim hybrid and tried it afterwards, oh boy :)

The main advantages of Spacemacs, IMO, are its community creating good quality layers, the concept of layers itself (think of it as a group for a major mode and its associated minor modes - makes config a lot cleaner), running almost everything through helm-mode (which isn't fun to integrate that well yourself), and its space leader key (hence spacemacs) on top of helm-mode giving you self-documenting navigation through every single command.

So saving files becomes "space f s" opening files is "space f f" and if you idle a few seconds at any point helm-mode shows you all the possible options, so its very easy to learn gradually.

I gotta admit I jumped headfirst into its tutorial and when I had completed it went on to read the full Spacemacs documentation, so most of the the learning curve was rather easy over a week or two, yet months later I'm still learning new things :)

Re: Vim Anti-Patterns

#228

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…

My main focus is on modal navigation, editing and dealing with text as objects - that's the real long-term benefit Vim gives me.

For new users selecting one I think this comes down what you're looking for from the application and the plugins/community around them. But, I really don't think there's any killer differences between them, it's just a matter of taste.

For you:

> I came to Emacs because of Lisp (and general FP audience is much, much, more based around Emacs, > makes sense), amazing tools and plugins which I found more stable, better designed, and it is weird > to say this but things just worked with Emacs, things like auto-completion

I recognise it's more popular to edit Lisp with Emacs, but Vim seems to do just fine. I play with Clojure and do that using Vim perfectly fine there are great plugins (fireplace etc). There's no doubt that the 'emacs is code' thing attracts Lispers to it.

Both, Emacs and Vim both have large ecosystems of tools and plugins around them so I consider that a non-issue.

In terms of configuration, I think Vim is easier to get started with. I personally consider Emacs system a steep learning curve for the general use-case. I find Vim is very well documented and has lots of settings for all the conceivable things you'd want, plus a raft of plugins to alter it's behaviour in the ways I want. However, the fact that Emacs can be rewritten in-itself is a powerful concept so in principle you can't see an advantage there.

In the past people used to say that Vim was smaller and that was a reason to use it over Emacs, but that's a total non-issue for the general use case.

I don't think it really matters which one you choose, as long as you spend some time getting to know 'it' properly.

Re: Vim Anti-Patterns

#229
post #85

Moving to the far left-corner of the keyboard to reach Escape has been a major annoyance for me. On the other hand, the Caps Lock key on my keyboard is almost useless. I never use that key. Is there a way to map Caps Lock to Escape in Vim?

[deleted]

Re: Vim Anti-Patterns

#230
post #85

Moving to the far left-corner of the keyboard to reach Escape has been a major annoyance for me. On the other hand, the Caps Lock key on my keyboard is almost useless. I never use that key. Is there a way to map Caps Lock to Escape in Vim?

Run setxkbmap in your .xinitrc if applicable: setxkbmap -option caps:escape Linux desktop environments’ keyboard configuration tools should also let you do this.

I am using Windows. Is there a lightweight solution to map Caps Lock to Escape on Windows?
Post reply on HN