Live data from Hacker News

How to boost your Vim productivity

sheerun.net

111–120 of 130 posts

Re: How to boost your Vim productivity

#111
post #30
post #9

Earlier quoted context omitted.

Lord, that's so useful. I normally include a move to next line part in my macro and then guess at how many times to run it (20@q, repeat until I get it right). It's actually the main reason I often don't bother using macros. This is such a great tip. Thanks!

You can combine regexes with macros if you only wish to run your macro on a particular set of lines: :' g/foobar/norm @q will run the macro only on the subset of selected lines that match the regex "foobar". :g/.../ will match the regex against all lines in the file.

I love the g command. Very useful to quickly cull out lines of stuff that you don't want in your file. g/foobar/d

Re: How to boost your Vim productivity

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

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

Well you're leaving the middle columns there, then on your first keystrokes it would be acutally {+down+left as Sublime does not put cursor back at beginning of line when going down. In all I used 26 keystrokes in Sublime, and 27 in Vim. Also, if you understand Vim's vocabulary, the "cognitive overhead" is, as you put it "far less" in Vim's favor. IMO.

Re: How to boost your Vim productivity

#113
post #99
post #96

Earlier quoted context omitted.

Er, I've done this with Visual Studio... just export your settings as an XML file, import them in the new install, and of course install VsVim[1], and you're good to go. [1] https://github.com/jaredpar/VsVim

Big difference: 1. You have to import/export every time a change is made! 2. Visual Studio takes like 6 hours to install.

1. https://msdn.microsoft.com/en-us/library/2253f386(v=vs.110).... solves that issue.

2. I install VS quite a bit, it's not that long at all. More time than sublime et all though, agreed. I usually have it as my "parallel" process while I go clone my repos.

Re: How to boost your Vim productivity

#115
post #46
post #34

Earlier quoted context omitted.

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."

this is awesome, can you please suggest some resources for me, a long-time basic user of vim, ( know a lot of commands for actions, but not the underlying relationships?

Re: How to boost your Vim productivity

#116
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 machin…

I just use Vim Bootstrap. It gives me a pretty good setup without adding a tonne of stuff I don't need.

From memory I've only changed about 5 lines in my vimrc ? enabling mouse and setting indentation levels for some less common filetypes.

Re: How to boost your Vim productivity

#117
post #90

Earlier quoted context omitted.

FYI: there is a setting that flips everything around – F1 to get F1, Fn+F1 to lower the brightness.

But it's also not the default (at least on OSX).

'It's not the default' is a terrible argument in a thread specifically about customising vi to the Nth degree ;)

Re: How to boost your Vim productivity

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

Something i've been using more lately is Ctrl-R + Register. Great for inserting text in command mode. For instance, you can do this to insert your recorded macro (if it's in register q) as a norm command: :norm Ctrl-R q

Re: How to boost your Vim productivity

#119
post #66

Earlier quoted context omitted.

Additionally, on many keyboards (specifically Apple keyboards), you have to hit a modifier key plus the function key. For example, you have to hit Fn + F1 to get F1 because otherwise it's the "Lower LCD Brightness" hotkey. This makes them even less useful.

FYI: there is a setting that flips everything around – F1 to get F1, Fn+F1 to lower the brightness.

Not always useful if e.g. you're locked out of the BIOS, the setting constantly auto-resets for no apparent reason, the keyboard is partially broken.

The sad thing is that I've personally experienced all three of these problems. #%^$ whoever decided that the Function keys should be brightness etc by default.

Post reply on HN