Last active
January 1, 2016 22:09
-
-
Save AndrewRadev/8207806 to your computer and use it in GitHub Desktop.
Attempt to make simpler (and more limited) macros in Vim.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Press `M` to start recording in a predefined register, press `M` again to | |
" stop. The dot mapping (`.`) now executes the macro. | |
let s:simple_macro_active = 0 | |
nnoremap M :call <SID>SimpleMacro()<cr> | |
function! s:SimpleMacro() | |
if s:simple_macro_active == 0 | |
call feedkeys('qm', 'n') | |
let s:simple_macro_active = 1 | |
elseif s:simple_macro_active == 1 | |
normal! q | |
" remove trailing M | |
let macro = @m[0:-2] | |
call repeat#set(macro, 1) | |
let s:simple_macro_active = 0 | |
endif | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment