Live data from Hacker News

Vim Anti-Patterns

sanctum.geek.nz

241–249 of 249 posts

Re: Vim Anti-Patterns

#241
post #186

Earlier quoted context omitted.

Plug for Karabiner on OS X, which lets you use capslock as a control if you press it with another key, and escape if its released on its own. It has ruined me for other computers that don't have this set up. There's also a way to do it under Linux, but I can't remember what the package is that lets you do that.

You're thinking about xcape: https://github.com/alols/xcape . FYI, Karabiner is incompatible with MacOS Sierra. There's a project (Karabiner-Elements) to replace its (and Seil's) functionality, but I don't believe it has feature parity yet: https://github.com/tekezo/Karabiner-Elements

Wow thanks for the heads up... that would have been a shitty thing to discover the hard way!

Re: Vim Anti-Patterns

#242
post #145

Earlier quoted context omitted.

Pretty funny. I found myself asking "What does C-x do when autocompleting?" I took the 'x' literally, instead of realizing you meant C-n, C-p. xD

x is literal. For context aware auto complete of a word try C-x C-n/p. For a line try C-x C-l. For a directory do C-x C-f. And remember that this is context aware, you can hammer C-x C-n C-x C-n or C-x C-l C-x C-l. Stuff is really powerful. Changed the way I program and I never see enough articles mention it.

Ah, this should really be easier to find in the vim docs. I did ":help ^x" and only came up with:

CTRL-X Subtract [count] from the number or alphabetic character at or after the cursor. {not in Vi}

After trying again today, I could not find any thing on context-aware completion no matter what help commands I tried. And I can usually find what I'm looking for there.

When I tried C-x in insert mode a couple of days ago, I'm not sure how I missed the: "-- ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y)" string that appears in the mode line. Perhaps I saw it and didn't grasp what it was.

I'm always amazed after so many years of using vim how many new things there are to learn about it.

Re: Vim Anti-Patterns

#243
post #183
post #145

Earlier quoted context omitted.

Pretty funny. I found myself asking "What does C-x do when autocompleting?" I took the 'x' literally, instead of realizing you meant C-n, C-p. xD

In insert mode, C-x actually lists the different completion methods, so it's actually accurate. ^X mode (^]^D^E^F^I^K^L^N^O^Ps^U^V^Y) I really like having C-x C-f, which autocompletes file names.

yeah, see my reply to the parent below. :D

Re: Vim Anti-Patterns

#244
post #205
post #103

"Hitting Escape is usually unnecessary; Ctrl+[ is a lot closer, and more comfortable." I agree with a lot of the things in this article, but wow, I could not possibly disagree with this quote more. Ctrl+[ is WAY more uncomfortable than using the Escape key. Granted, I have many years of vim usage that have made hitting Escape a habit, and that probably plays a big part in it, but Ctrl+[ is downright painful for me (a…

> I could not possibly disagree with this quote more. Ctrl+[ is WAY more uncomfortable than using the Escape key. Did you try it with one hand or two. I do it by using my left pinky on the ctrl key and my right pinky on the [ key. In general, I've always tried to stick with the touch typing convention where you use the modifier key on the opposite side of the keyboard relative to the key you press. For example, I wil…

"Did you try it with one hand or two."

^^ was this supposed to be a joke? (I laughed at first when I thought you meant stretching the left hand between the left CTRL key and the [ :-D ).

I guess I could see someone trying to type it one-handed with their right hand, but I would have never even have thought to do that (and I don't know that I ever use the right CTRL key anyway).

Outside of the CTRL keys, I touch type pretty much everything normally, with very few exceptions (like using my ring finger on Escape). I find moving my right pinky to the right CTRL key to be very uncomfortable, so I just always use the left CTRL key.

Re: Vim Anti-Patterns

#245
post #139
post #103

"Hitting Escape is usually unnecessary; Ctrl+[ is a lot closer, and more comfortable." I agree with a lot of the things in this article, but wow, I could not possibly disagree with this quote more. Ctrl+[ is WAY more uncomfortable than using the Escape key. Granted, I have many years of vim usage that have made hitting Escape a habit, and that probably plays a big part in it, but Ctrl+[ is downright painful for me (a…

ctrl+[ is closer but with an already over-used right pinky it is a bad idea. i much prefer jk as .

yeah, and with the only Ctrl-[ option that I would consider, you are having to use both pinkies simultaneously. I have a feeling I would just end up missing all the time and getting irritated.

xD

Re: Vim Anti-Patterns

#246
post #178

Earlier quoted context omitted.

Ahg, no I couldn't do that, I need to keep J as Join lines. That's pretty useful to me. Kinda the inverse of gq.

Ah, I bound join lines to :join since I don't use it that often. I still encourage you to try binding something to 7j (or whatever number of j's feels right). One of the best shortcuts of my life.

I tried to use J, but it's somewhat tied to my muscle memory already (and I'm surprised I use it quite often joining comments and stuff). If you're like me, remember that you can abbreviate :join to just :j.

The advantage of using J and K is that they're very vim movements, but if can't because of :join, another workaround would be to use and since they're redundantly bounded to and :

    nnoremap  7j
    nnoremap  7k
    vnoremap  7j
    vnoremap  7k

Re: Vim Anti-Patterns

#247
post #244
post #205

Earlier quoted context omitted.

> I could not possibly disagree with this quote more. Ctrl+[ is WAY more uncomfortable than using the Escape key. Did you try it with one hand or two. I do it by using my left pinky on the ctrl key and my right pinky on the [ key. In general, I've always tried to stick with the touch typing convention where you use the modifier key on the opposite side of the keyboard relative to the key you press. For example, I wil…

"Did you try it with one hand or two." ^^ was this supposed to be a joke? (I laughed at first when I thought you meant stretching the left hand between the left CTRL key and the [ :-D ). I guess I could see someone trying to type it one-handed with their right hand, but I would have never even have thought to do that (and I don't know that I ever use the right CTRL key anyway). Outside of the CTRL keys, I touch type…

> I guess I could see someone trying to type it one-handed with their right hand

That's exactly what I was thinking of. Years ago, I used to press key combinations like ctrl-c, ctrl-x by moving my left hand away from the home row and using my pinky on the ctrl key and my index finger on the c or x key. I thought you may have been doing something like taking your right hand off the home row and pressing the key combination with your thumb and index finger.

But I do find that using the modifier key on the opposite side of the keyboard requires less contortion for a given key combination (e.g., the shift-v or ctrl-v combinations for linewise or blockwise visual mode).

Re: Vim Anti-Patterns

#248

Earlier quoted context omitted.

I don't want vi modality. I find it more annoying than emacs yoga-esque bindings. I want more sane emacs bindings.

You can make them yourself, and I think there are some packages for that as well.

Coming from evil-mode, I often have to make them myself, and it is a pain. Every mode needs new keybindings to fit in with whichever scheme you use. I imagine it would be worse with custom keymappings that aren't evil-mode, because I can at least use the default keybindings in input mode as-is with evil.

Re: Vim Anti-Patterns

#249

Earlier quoted context omitted.

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 e…

I tried this very briefly and thought "This seems useless." 1. It's annoying how they all change every time my cursor moves (though it'd be fine if I also did "scrolloff=999"), and g-4 doesn't work to jump up 4 lines.

Then I realized I could do y6k to pull the next six lines, rather than "told on, let me count/do the math on the line numbers". Took me another moment to realize "4j" is the way to move.

I think I'm going to like this.

Post reply on HN