Monday, October 23, 2017

Re: vim paste question

On 2017-10-23 03:21, dexter i wrote:
> i want to be able to emit the following lines into the file under
> current cursor position. <paste-buffer-word> is the word i just
> yanked. what's the best way to achieve this.
>
> {
> .testtype = <paste-buffer-word>; \
> .testtypestring = "<paste-buffer-word>"; \
> }

There are some templating plugins that make this easier, but if it's
a one-off, you could do something like

:nnoremap Q o{<cr><tab>.testtype = <c-r>0;<bslash><cr>.testtypestring = "<c-r>0";<bslash><c-d>}<esc>

Adjust for your padding-spaces before the <bslash> if you want, but
it would depend on the length of your pasted content. You could use
the expression register instead, something like

<c-r>=@0.repeat(' ', 50-strlen(@0))<cr>

and

<c-r>=@0.'"'.repeat(' ', 50-strlen(@0))<cr>

-tim



--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: