How to use vim-repeat
fdietze opened this issue · 1 comments
fdietze commented
Hi, I don't understand from the docs how to use vim-repeat with my own function. What I came up with is not working:
function! ToggleEndChar(charToMatch)
let save_cursor = getpos(".") " backup cursor
s/\v(.)$/\=submatch(1)==a:charToMatch ? '' : submatch(1).a:charToMatch
call setpos('.', save_cursor) " restore cursor
endfunction
nnoremap <silent> <Leader>, :call ToggleEndChar(',')<CR>\
silent! call repeat#set("ToggleEndChar(',')<CR>", -1)
What am I doing wrong?
tpope commented
You need to call repeat#set in the function, and you need to give it a valid Vim map (not just a function invocation).