News for hackers. Stuff that matters.
Re:What is your most productive shortcut with Vim? by jlgreco on Sunday October 20, 2013 @02:43AM (#6579125)
Not necessarily in line with what the SO question is asking for, but this is by far the best thing I have ever added to my .vimrc:

  " make space execute the 'q' macro (press qq to start recording, q to stop,    
  "       then [space] to execute.  super convenient)                            
  noremap <Space> @q
This streamlines making and executing macros to such a degree that I'll often do that instead of merely making 3 or 4 complex series of edits manually. You just perform the edit once, then get in a few satisfying "thwocks" on the spacebar.

(Note that to effectively create macros on the fly, you need to have a firm grasp on vi "as an editing language". If you are merely moving around with hjkl and otherwise treating it like nano, you aren't going to get much mileage out of this unless everything you are working on has the same number of lines.)

Re:What is your most productive shortcut with Vim? by qqqw on Sunday October 20, 2013 @02:58AM (#6579149)
Learning muscle memory for nonstandard mappings is a bad idea. I used "jk" as an escape for a long time. It's nicer than using esc, but no other program that has vim emulation supports mappings like that.

Also, you can do <num>@q (e.g. 4@q) anyways, and @@ to repeat a macro, so that isn't that useful of a remapping anyways.

Re:What is your most productive shortcut with Vim? by jlgreco on Sunday October 20, 2013 @03:11AM (#6579177)
> Learning muscle memory for nonstandard mappings is a bad idea.

People, especially vi users (compared to Emacs users, who in my experience have few qualms about heavily customizing their editor), like to say that, but in my many years of experience I just can't say this is true in practice. I don't use coworkers' accounts so alien configurations never trip me up, and when I find myself working on a prod host that doesn't have my configuration, I just don't find myself tripping up in practice (if I had to guess, perhaps the absence of my custom color scheme in those cases may be flipping a 'go back to compat mode' switch in my head).

I do not use any other programs that have "vim emulation". Tried that firefox 'total conversion mod' a while ago and hated it.

Executing macros the regular way is what I do for all macros I want to be long-lived (@q can get overwritten a dozen of times or more an hour for me, so complex operations I want to keep around longer I store in other registers), but even @@ does not have the low mental barrier to entry and satisfying nature that "twock" on a nice loud keyboard has.

(instead of [esc] for escape, I use [capslock] on windows and linux while on thinkpads, and [find](actually super) on linux on my chromebook. xmodmap/autohotkeys/xcape has my bases covered there.)

Re:What is your most productive shortcut with Vim? by sillysaurus2 on Sunday October 20, 2013 @03:03AM (#6579161)
Eh, I disagree. First, vim emulation is horrific -- absolutely horrific. With the exception of ViEmu, and possibly the new Emacs one (haven't had the chance to try it), there's not a single good Vim emulator. Second, @@ is two keystrokes, and it's incredibly annoying to type @@n@@n@@n@@n@@n@@n in order to invoke the macro 6 times. " n n n n n n" is much easier.
Re:What is your most productive shortcut with Vim? by qqqw on Sunday October 20, 2013 @03:14AM (#6579185)
What do you mean by "n"? Moving to the next position in a search? You can structure a macro to end with going to the position of next edit. Then you can hit 100@@ or whatever and do all of the edits in one go.
Re:What is your most productive shortcut with Vim? by sillysaurus2 on Sunday October 20, 2013 @03:25AM (#6579205)
Most of the time you want to individually review each instance of what the macro is doing before invoking it, so 100@@ is rarely used. (At least by me.)
Re:What is your most productive shortcut with Vim? by belden on Tuesday October 22, 2013 @06:08AM (#6590764)
Macros in vim can call themselves; so if you want to make an edit across an entire file, something like:

<esc>qqq //clear q macro qq //start recording q macro /foo // search for something 3clbar // do some edit @q // call q macro q //done recording @q //invoke q macro

No need to guess how many times to call your macro.

Re:What is your most productive shortcut with Vim? by justinmk on Tuesday October 22, 2013 @12:50AM (#6589851)
> there's not a single good Vim emulator

vrapper (for eclipse) is on par with emacs evil, actually.

https://github.com/vrapper/vrapper

Re:What is your most productive shortcut with Vim? by lowboy on Sunday October 20, 2013 @03:08AM (#6579171)
@@n.n.n.n.n.n. isn't much worse than the version with spaces.

edit: but . doesn't work for macros, as was pointed out.

Re:What is your most productive shortcut with Vim? by sillysaurus2 on Sunday October 20, 2013 @03:10AM (#6579176)
. can't invoke a macro.
Re:What is your most productive shortcut with Vim? by lowboy on Sunday October 20, 2013 @03:12AM (#6579182)
Huh, so it can't.
Re:What is your most productive shortcut with Vim? by splawn on Monday October 21, 2013 @11:44AM (#6586242)
evil-mode is fantastic. (I think it might be the new one you haven't tried yet) combined with key-chord mode, it will handle the "jk mapped to esc" use case, I have mine mapped to "jj"

(key-chord-define evil-insert-state-map "jj" 'evil-normal-state)

Re:What is your most productive shortcut with Vim? by mtdewcmu on Sunday October 20, 2013 @02:57AM (#6579144)
I use . constantly to redo a command, but I haven't come around to macros. May be worth a try.
Re:What is your most productive shortcut with Vim? by justinmk on Tuesday October 22, 2013 @12:43AM (#6589818)
Why not remap to @@ so that you can repeat the last macro, instead of just the q macro?

    nnoremap <space> @@
Re:What is your most productive shortcut with Vim? by sillysaurus2 on Sunday October 20, 2013 @02:57AM (#6579143)
Wow, that's fantastic! Thanks.