Live data from Hacker News

How to boost your Vim productivity

sheerun.net

121–130 of 130 posts

Re: How to boost your Vim productivity

#121
post #18

Why don't people seem to use the F keys? I have mappings for very frequent functions on F1-F5, and it really helps: map :w | "Fast save imap :w | "Fast save map :make | "Fast compile map :bn map :bp " Same mapping for gnome-terminal ( see http://stackoverflow.com/q/12813126/164171 ) map ^[O1;2R :bp map :bd | "Close buffer map :cnext map :cprev imap :cnext imap :cprev

I'd guess, for the same reason I use Ctrl-[ instead of the Esc key. F keys put you out of the home row (at least in full size keyboards).

You can remap your Caps Lock key to Esc on pretty much everything: Windows using AutoHotKey, Mac OS using Seil, Unix using xmodmap.

Re: How to boost your Vim productivity

#123

This was great even just for the p "+p mapping. I do this all the time ("+p). It's weird because I tend to go through waves of realizing "Oh! I can just remap that!" I feel like I have fairly good vim skills but somehow always forget I can keep making it more efficient than it already is. Thanks for the reminder =].

I've got vim set up to use the system clipboard automatically. Want to visit a URL in a readme file? yiW, tab over to chrome (with vimium), hit P to open it in a new tab. Want to add a URL to documentation? yy it from chrome, tab to terminal, p it in.

Re: How to boost your Vim productivity

#125
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,…

Well said gramps. People don't get that juggling text "more productively" is not what makes or breaks a programmer. What makes or breaks a programmer is their ability to think productively, i.e. how well can you formulate a plan of attack for a given problem before you get to the keyboard, and there ain't no tool out there that can make that any easier.

Re: How to boost your Vim productivity

#126

Earlier quoted context omitted.

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?

I don't know if I am understanding your question correctly.

I read 'ci(' as change what's inside parents. I read 'ci{' as change inside braces. 'ca(' and 'ca{' grab the parents and the braces as well.

=========================

These combinations work for (d)elete as well. If your cursor is over the 4th letter of a 6 letter word, 'dw' will delete to the end of the word. 'diw' on the other hand will delete the whole word. (I've never tried 'daw' although I know 'da(' works)

Re: How to boost your Vim productivity

#127
post #3

In my 6 years of coding and writing LaTeX in Vim, I have found that the greatest boost to my Vim productivity is learning all about the vi and ex foundation of Vim. My Vim knowledge applies 100% to any default Vim installation on a modern distro, and my vimrc contains mostly trivial tweaks. This means using :normal and macros instead of :s for most of my search/replace actions; using H, M, L, {, } to navigate quickly…

> I specifically don't have mappings that involve the leader key, and I don't use the Ctrl-P plugin or a package manager or anything like that -- I honestly don't think that mapping w to :w will make me any more productive in Vim. I'm not as much of a purist, but that line jumped out at me too. For me, the attraction of vim is primarily in raw out-of-the-box editing power and ubiquity. Relying on custom binds for bas…

While all of that is correct, it's also the core of vim philosophy that using 2 key strokes instead of 3 is what speeds you up. That said I also haven't used too fancy configuration or mapping or plugins in vim yet because I fear I don't have them when I ssh into another system, which happens quite often. But I have to say that I use a few aliases in git and that speeds me up a lot, as long as I stay on my system.

Re: How to boost your Vim productivity

#128

Earlier quoted context omitted.

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?

I don't know if I am understanding your question correctly. I read 'ci(' as change what's inside parents. I read 'ci{' as change inside braces. 'c a (' and 'c a {' grab the parents and the braces as well. ========================= These combinations work for (d)elete as well. If your cursor is over the 4th letter of a 6 letter word, 'dw' will delete to the end of the word. 'diw' on the other hand will delete the whol…

right. I guess what I meant was 'c' and 'd' are usually followed by movements, so stuff like 'dt)' makes sense to me. 'i' on the other hand is not a movement, so the behavior of 'di)' was surprising to me.

It's because 'iw', 'aw', and the like are commands of their own when an operator like 'c' or 'd' precedes [1]. So 'di)' is interpreted as 'd' followed by the 'i)' command (if I'm interpreting it correctly!), not as 'd' followed by 'i' followed by ')', which is nonsense.

I hope that was clear - just trying to understand vim better :)

[1]: http://vimdoc.sourceforge.net/htmldoc/motion.html#text-objec...

Re: How to boost your Vim productivity

#129
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,…

It really depends on what type of plugins you're talking about.

The ones that highlight syntax errors in python, or js, or that spit out compilation errors for C are a must, and one of the most important features for me.

The plugins that take hours to configure, and let you press on key instead of three for some infrequent action: yes, avoid them. No matter how fancy they look, and how well someone tries to sell it to you.

CtrlP is also a must for me. Instantly open any file, even if I vaguely recall it's name. And no configuration necessary (though you can optionally tweak it a bit).

Re: How to boost your Vim productivity

#130
post #94
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 started feeling the same, about the configuration time sinks ... my solution was to create ansible-configurable docker images with everything setup ... so I can throw away and recreate the images once a month, when the plugins get screwed up (which they really do, about once a month or so!): - Go version: https://github.com/samuell/devbox-golang - Python version: https://github.com/samuell/devbox-python I love bein…

Why not handle the configurations with git? Handling dotfiles with git is pretty common nowadays, and you can roll back/forward as you please.

Plus, the overhead is a lot less.

Post reply on HN