How can I repeat not only the last used modification(.) but also more earlier ones?

Perfect variant would be choose them by Ctrl-N and Ctrl-P

link|improve this question

40% accept rate
feedback

3 Answers

I wouldn't recommend remapping C-N and C-P, since they are autocompletion mappings, and often plugins use them. As a matter of fact, I wouldn't recomment remapping any of vim's default mappings. But anyways, that's up to you.

As far as repeating goes, the dot (.) will repeat the things you did on your last row. If you are having some problems with repeat command with some plugins, try the repeat.vim plugin.

If you wish to have some opeations which you use often at your disposal, try recording it in a register and then playing it (":help record"), or making it a function and then calling the function (if you do wish, I guess the call to function could be made as C-N or C-P ...)

link|improve this answer
qq - macros ftw =) – akira Oct 4 '09 at 9:10
q[a-zA-Z] actually :) – ldigas Oct 4 '09 at 11:58
(good) plugins should not be upset by custom mappings, since they can circumvent them with :noremap – accolade Feb 25 at 0:23
feedback

To expand on @ldigas' comment about record and macros, here is a simple breakdown.

  1. Press q to enter "record" mode.
  2. Press what key you want to "name" the macro, I usually use w for one-time-use macros, but you can use any letter you want.
  3. Perform the operations you want to repeat.
  4. Press q to stop recording.

Once you have your macro, you can replay it by using @w (assuming you used w), and it will roll through the actions you recorded.

link|improve this answer
+1 I also like @@ for repeat the last run macro. – tidbeck Feb 25 at 10:24
feedback

Again expanding on mapping your commands to be repeated:
When you know without visual feedback what you want to repeat, this [Ctrl-]Space mapping saves another few keystrokes:

" map in Normal and Visual modes, but not Select mode (see :help mapmode-x
:command -nargs=*  Nxmap      nmap     <args>| xmap     <args>
     com -nargs=*  Nxnoremap  nnoremap <args>| xnoremap <args>
     com -nargs=*  Nxunmap    nunmap   <args>| xunmap   <args>

" map <Space> to currently often-used operations (similar to space.vim)
    " quickly create custom mappings
        " Usage: <C-Space>YOURMAPPING<Enter> and then just <Space> for each repetition
        " (When you know without visual feedback what you want to repeat, this saves another few keystrokes.)
    Nxmap <C-Space> :Nxmap <lt>Space> 

    " make these commands repeatable by <Space> (similar to space.vim)
    let space_repeats_nx = ['@@','@:']
        for cmd in space_repeats_nx
            exe 'Nxnoremap '.cmd.' :Nxnoremap <lt>Space> 'cmd.'<CR>'.cmd
        endfor
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.