I have the textobjects-user and textobject-quotes plugin installed, using vim 8. Those let me work with multi-line strings, so I can place the cursor inside a multi-line quoted string and diq
to delete or yiq
to yank. Those text objects work so I know the plugin works.
I tried to define a simple key remap so I could yank the contents of a quoted string, open it in a new split, and strip excess whitespace:
nnoremap <leader>Q yiq<CR>:vnew<CR>p:%s/^\s\+//<CR>
It doesn't work. If I remove the yiq<CR>
and do that from the keyboard, then invoke <leader>Q
the split and paste and whitespace stripping work. If I change yiq
to yi'
it works.
Any reason I can't use the plugin's text objects inside a remap like this?