I have a function (from here) that requires an argument enclosed in quotes.
if !exists('*Preserve') function! Preserve(command) try " Preparation: save last search, and cursor position. let l:win_view = winsaveview() let l:old_query = getreg('/') silent! execute 'keepjumps' . a:command finally " try restore / reg and cursor position call winrestview(l:win_view) call setreg('/', l:old_query) endtry endfunction endif
I want to put this in a macro. I have tried,
let @d=':call Preserve(":normal ?^# ^Mjo## DESCRIPTION^]")'
let @d=':call Preserve('':normal ?^# ^Mjo## DESCRIPTION^]'')'
and various other ways, but nothing works.
How do I create a macro that calls this function without errors?
Among the answer was the suggestion that I simply record the function. That's good. However, I keep a list of frequently-used macros in the form:
let @d='<contents of macro>'
The reason is, some of the macros are very long, and occasionally I lose them from the registers and need to re-load them so-to-speak. Having to manually record the macro again would be a PITA. (BTW I'm aware I could perhaps record the function call and then append it (eg.
qD) to a macro created with
:let @d='[...]; but this is far from optimal.)
So, is it at all possible to
:call a function (as above) without running into errors with quoting?