Live data from Hacker News

How to boost your Vim productivity

sheerun.net

51–60 of 130 posts

Re: How to boost your Vim productivity

#51
post #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

I read the help, it's pretty awesome. There's a few bindings in there that I had no clue existed, like Ctrl-w {H J K L} to rotate windows, and ctrl-w f to split window and edit the file under the cursor. My problem is that the default bindings are just a pain to type. Ctrl-w + is a lot of work when you have your window navigation bindings set to CTLR - { h j k l }

Re: How to boost your Vim productivity

#53
post #24

Earlier quoted context omitted.

...% to navigate quickly within a line. "%" works fine for moving around, but when I use it to edit it always surprises me, which direction it goes. I almost think vim is psychic, because "%" goes the wrong direction for me at least 80% of the time. There must be a deterministic rule governing this, but can anyone explain to me what it is?

Find first brace to the right of the cursor (be either an opening or closing brace) and jump to the matching one. If the cursor is at the beginning of a line of matched parentheses, % will go to the closing parenthesis of the first group, as in my example in a cousin comment.

Thanks for this! My mental model of this was really wrong.

Re: How to boost your Vim productivity

#54
post #40

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.

I rarely resize windows, but when I do, I set mouse=a and use the mouse to drag the window borders around. There's also CTRL-W _ (underscore) to maximize the current window and CTRL-W = to make window sizes equal.

I'm in the same boat, rarely re-sizing windows, and I'd do the same thing, but I use Tmux and terminal Vim and using the mouse there just doesn't work in my terminal emulator. (I use st[0] on Linux. It probably would work in iTerm on Mac, but I haven't tried.) It also may not work due to Tmux being configured with mouse support.

[0] http://st.suckless.org/

Re: How to boost your Vim productivity

#55
post #40

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.

I rarely resize windows, but when I do, I set mouse=a and use the mouse to drag the window borders around. There's also CTRL-W _ (underscore) to maximize the current window and CTRL-W = to make window sizes equal.

Also, did you know that Ctrl-w | maximizes the a window horizontally? So if you have splits open above and beside you ctlr-w _ ctrl-w | will maximize your current split.

immediately maps this to ctrl-w m

Re: How to boost your Vim productivity

#56

Earlier quoted context omitted.

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.

I don't think the speed hit you take when you actually have to type 'jk' should be a dealbreaker. It rarely comes up, and when it does, you can use e.g. 'jk' or 'jjkak'.

Re: How to boost your Vim productivity

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

  /^\(\S*\)\s*\S*\s*\S*\s*\(\p*\)
  :%s//{\1, "\2"},
"Now they have two problems."

Re: How to boost your Vim productivity

#59

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.

You can use "set winwidth=79". It'll automatically resize active column to at least 79 characters.

I also use mouse for resizing.

Re: How to boost your Vim productivity

#60
It is a long long time ago that someone taught me something really new about vim and used plugins that are not just fancy (looking at most status line plugins or nerdtree) but actually seem to improve productivity in a vim-ish sense. Kudos!
Post reply on HN