Live data from Hacker News

How to boost your Vim productivity

sheerun.net

41–50 of 130 posts

Re: How to boost your Vim productivity

#41
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 basic actions really hurts the ubiquity half of the equation. And really is :w where one wastes time in vim? If I wanted to customize everything I'd probably switch to emacs.

Still, it's interesting to see how many different ways vim can be optimized according to individual workflows.

Re: How to boost your Vim productivity

#42
post #20

Lately I use neovim, because it allows using 24 bit color themes in the terminal.

So neovim is usable now? Do you run into many problems with it?

So far the only issue was some slowness when it uses xsel over ssh. I don't think it should take that long because of network alone. Otherwise - it's very good.

Re: How to boost your Vim productivity

#43

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

ICBW, but I believe Ctrl-[ is already available, and works the same.

For me, having remapped Capslock to Ctrl, this is a dead simple way of hitting Esc without going as far off homerow.

Re: How to boost your Vim productivity

#45

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

ICBW, but I believe Ctrl-[ is already available, and works the same. For me, having remapped Capslock to Ctrl, this is a dead simple way of hitting Esc without going as far off homerow.

I had jk mapped for a long time and thought it was safe. Then one day I actually had to type it as text, and it took me a moment to figure out what was wrong. I'm retraining myself to use ^[ now.

Re: How to boost your Vim productivity

#46
post #34
post #10

Earlier quoted context omitted.

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…

I just spent minutes to parse that instruction. Mind blown. Thank you for this enlightenment.

You need to know how dw, de, cw, ce relate to each other, when the cursor is on a token character vs. a whitespace character, and so on, in order for this to be truly useful -- but luckily, ordinary practice with those commands in Vim can lead to an efficient internal idea of how it works. "You get used to it, though. Your brain does the translating. I don't even see the code. All I see is blonde, brunette, redhead."

Re: How to boost your Vim productivity

#47

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.

^W20+ - increase the current window height by 20 lines ^W20> - increase the current window width by 20 columns

:he ctrl-w

edit: typo

Re: How to boost your Vim productivity

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

Wow I have only been using H and L, and only because of you have I come to know M, {, and }. Thank you!

But would you mind giving an explanation as to what the other things you listed do (f/F/t/T/;/,)?

From just playing with them, it seems like f goes to the next character that you type and F does the same but backwards. t/T does the same but instead of going to the character it goes one before/after.

I can't figure out what , and ; are for though..

Re: How to boost your Vim productivity

#49
post #48
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…

Wow I have only been using H and L, and only because of you have I come to know M, {, and }. Thank you! But would you mind giving an explanation as to what the other things you listed do (f/F/t/T/;/,)? From just playing with them, it seems like f goes to the next character that you type and F does the same but backwards. t/T does the same but instead of going to the character it goes one before/after. I can't figure…

They are documented in :help left-right-motions, which you can also read at http://vimdoc.sourceforge.net/htmldoc/motion.html#left-right....

fx moves the cursor to the next occurrence of x, and semicolon repeats the search. To repeat the search in the opposite direction, use comma. 4tx moves the cursor right before the 4th occurrence of x right of the cursor in the line. F and T move backwards instead of forwards; in that case, semicolon continues moving backwards and comma moves forwards (similar to / ? n N).

It takes a while to get used to, but it has made me much more efficient compared to when I just pressed wwwww or eeeee or bbbb to get where I wanted in a line.

Post reply on HN