Live data from Hacker News

How to boost your Vim productivity

sheerun.net

101–110 of 130 posts

Re: How to boost your Vim productivity

#102
post #87

Step 1 for those who really want to boost productivity (but let's be honest, most of us don't!): forget about all those plugins that are time sinks to configure and integrate with each other, about obscure tweaks that take half a day to get right, and about elaborate .vimrc's that take you so far away from 'standard' that you're crippled without them. Stick to a fairly basic standard install and a .vimrc of 50 lines,…

I've been cutting down on plugin use and esoteric mappings because of similar reasons but 50 is really small. I still hover around 10ish plugins, some of them are language dependent to help with indentation. Some of them just aid in intergrating with tmux or git, make it just a bit easier to open a file (ctrlp), or some show syntax errors.

Without stuff like that I'm still fine should I find myself on a remote machine. But I don't see an issue with making myself more comfortable than just being 'fine' on my personal setup where I spend most of my time.

I think the key is to vet your plugin and mapping choices to ones that expand upon vim in some way and avoid those that override core functionality or prevent you from learning them. If you do that you should be fine without imposing an arbitraty vimrc length.

Re: How to boost your Vim productivity

#103

Does anyone have any advice on bindings to change split size? Ctrl-w + and Ctrl-w - just don't work well, and my current configuration shadows Ctrl-a, which I really would like to avoid.

It might be dangerous, and I recognize it's one of the less portable aspects of my (old) vimrc, but I used to set up and down arrows to split resizes, and left and right to prev/next buffer.

Re: How to boost your Vim productivity

#104

The most productive mapping ever: imap jj . No more having to reach for the escape key.

Even better: imap jk imap kj I just hit both and j at the same time with my pointer and index fingers so it's essentially one keystroke.

How does this work? What if you are in insert mode and actually want to type j or k?

Re: How to boost your Vim productivity

#105

Earlier quoted context omitted.

Even better: imap jk imap kj I just hit both and j at the same time with my pointer and index fingers so it's essentially one keystroke.

How does this work? What if you are in insert mode and actually want to type j or k?

It's the combination jk (or kj) that is set up to switch from insert to normal mode. The idea is that this combination rarely occurs in English text. The drawbacks are a slight delay in cursor movement when typing j or k as vim waits to see what comes next, and momentary confusion when you inevitably need to actually insert these sequences.

Re: How to boost your Vim productivity

#106

Earlier quoted context omitted.

when I learned about f and F a whole new world opened up for me. It never ceases to amaze me how amazing vim is. Another quick thing I recently learned (yes, novice vim user here) is stuff like this \includegraphics{test.png} if you stand inside the curly brackets and type ciB (change in Brackets) you get this \includegraphics{} with your cursor active inside the brackets, just awesome ..

TIMTOWTDI: ci{ does the same (I think of "B" as beginning of a Word [including punctuation], so it would confuse me to use the "B" meaning braces)

nice. I was wondering how one would accomplish the same with parens, i.e. ci(. Why does this work? It doesn't seem to match the usual building of commands. I mean this obviously isn't c command followed by i command followed by paren. Is it just special?

Re: How to boost your Vim productivity

#107

The most productive mapping ever: imap jj . No more having to reach for the escape key.

Map Caps Lock to Ctrl. Then use Ctrl-C. You can keep your hand in home row.

I have done something similar: I mapped Caps Lock to Esc on system-wide level, and it has been remarkable since.

The only pitfall is when you start using someone else's computer and putting caps everywhere.

Re: How to boost your Vim productivity

#108
post #10

Earlier quoted context omitted.

Isn't :%s/.)/hello)/ simpler? Maybe that's because I know nothing about macros. Thanks for the explanation.

Pardon, it might have been a trivial example. I managed to find a real-world example I encountered in February this year. The PAPI library has a utility program papi_avail which prints a table of supported performance counters. The lines may look like this: PAPI_VEC_SP 0x80000069 Yes Single precision vector/SIMD instructions PAPI_VEC_DP 0x8000006a Yes Double precision vector/SIMD instructions PAPI_REF_CYC 0x8000006b…

You can do this with a few shortcuts in sublime. It requires about the same number of keystrokes, but far less cognitive overhead.

    { down { down {
to insert all three leftmost brackets.

    up up up
to go to first bracket.

    shift+left
to select first bracket.

    cmd+d cmd+d cmd+d
to select all three next brackets including the first.

    ctrl+shift right
to move all three cursors to the end of word.

    comma space "
to type your characters with all three cursors.

    cmd+right
to go to end of line with all three cursors.

    " } ,
to type your characters with all three cursors.

21 presses (29 keys), compared to your 32. And all I had to think about was where the cursor was.

(Not to be pedantic, of course!)

Re: How to boost your Vim productivity

#110

The most productive mapping ever: imap jj . No more having to reach for the escape key.

I much prefer mapping Caps Lock to Escape at a different level (with xcape -- caps is both my i3 modifier and my Escape key). That way, when I SSH into something and use vim or a shell it still works (or when I vim as root), and anything with a vim mode will just work.
Post reply on HN