|
|
| Line 20: |
Line 20: |
| |
" vim supports this by @: but there are cases when I want to press one key only |
|
" vim supports this by @: but there are cases when I want to press one key only |
| |
" and other cases I want to user other commands as well. |
|
" and other cases I want to user other commands as well. |
| − |
" Having to type :map <F5> :<cmd><CR> does need some time and I'm lazy ;-) |
+ |
" Having to type :map <F5> :<cmd><CR> does need some time and I'm lazy ;-) |
| |
" So just copy this text, put it into .vim/plugins/mapFromF1ToF12.vim and enjoy |
|
" So just copy this text, put it into .vim/plugins/mapFromF1ToF12.vim and enjoy |
| |
" Try |
|
" Try |
| − |
" :echo "dummy"<CR> |
+ |
" :echo "dummy"<CR> |
| − |
" <F5> |
+ |
" <F5> |
| |
" now you can use F5 to execute :echo "dummy" |
|
" now you can use F5 to execute :echo "dummy" |
| |
" Perhaps you want to have mappings local to your buffer only. |
|
" Perhaps you want to have mappings local to your buffer only. |
| − |
" Then use map <buffer> and unmap <buffer> instead |
+ |
" Then use map <buffer> and unmap <buffer> instead |
| |
|
|
|
| |
function MapLastCommandToKeys(keysToMapTo) |
|
function MapLastCommandToKeys(keysToMapTo) |
| |
exe "unmap ".a:keysToMapTo |
|
exe "unmap ".a:keysToMapTo |
| − |
exe "map ".a:keysToMapTo." :".histget("cmd")."<CR>" |
+ |
exe "map ".a:keysToMapTo." :".histget("cmd")."<CR>" |
| |
endfunction |
|
endfunction |
| |
|
|
|
| |
function PrepareMap(keysToMapTo) |
|
function PrepareMap(keysToMapTo) |
| − |
exe "map ".a:keysToMapTo." :call MapLastCommandToKeys('".a:keysToMapTo."')<CR>" |
+ |
exe "map ".a:keysToMapTo." :call MapLastCommandToKeys('".a:keysToMapTo."')<CR>" |
| |
endfunction |
|
endfunction |
| |
|
|
|
| |
" This will allow you to use F1 |
|
" This will allow you to use F1 |
| − |
PrepareMap('<F1>') |
+ |
PrepareMap('<F1>') |
| |
" This while loop will allow you to use F2,F3,..,F12 |
|
" This while loop will allow you to use F2,F3,..,F12 |
| |
let i=2 |
|
let i=2 |
| − |
while i<13 |
+ |
while i<13 |
| − |
call PrepareMap('<F'.i.'>') |
+ |
call PrepareMap('<F'.i.'>') |
| |
let i=i+1 |
|
let i=i+1 |
| |
endwhile |
|
endwhile |
" A little nice idea I got today...
"
" I've noticed that I often use one session mappings .. Sometimes :bn
" sometimes :make specialtarget
" in each case I need it often.
" vim supports this by @: but there are cases when I want to press one key only
" and other cases I want to user other commands as well.
" Having to type :map <F5> :<cmd><CR> does need some time and I'm lazy ;-)
" So just copy this text, put it into .vim/plugins/mapFromF1ToF12.vim and enjoy
" Try
" :echo "dummy"<CR>
" <F5>
" now you can use F5 to execute :echo "dummy"
" Perhaps you want to have mappings local to your buffer only.
" Then use map <buffer> and unmap <buffer> instead
function MapLastCommandToKeys(keysToMapTo)
exe "unmap ".a:keysToMapTo
exe "map ".a:keysToMapTo." :".histget("cmd")."<CR>"
endfunction
function PrepareMap(keysToMapTo)
exe "map ".a:keysToMapTo." :call MapLastCommandToKeys('".a:keysToMapTo."')<CR>"
endfunction
" This will allow you to use F1
PrepareMap('<F1>')
" This while loop will allow you to use F2,F3,..,F12
let i=2
while i<13
call PrepareMap('<F'.i.'>')
let i=i+1
endwhile
" of cause you can use any mapping eg \a:
PrepareMap("\a")
Recordings can do much more (encompassing other modes) than handle :cmd-line executions. They can also be repeated. See :help complex-repeat.
From normal mode,
- To record to register a: 'qa'
- Perform any keystrokes and :cmd-line executions.
- To stop recording: 'q'
- To perform recording 2 times: '2@a'
- To perform recording 55 more times: '55@@'