Wednesday, July 2, 2014

Re: map a chain of commands

On 2014-07-02 21:01, Tarlika Elisabeth Schmitz wrote:
> I use a clibboard manager and have a history of 50.
>
> >- do you only want to do this if *all* of the fields are non-empty,
> > or *any* of the fields are empty?
>
> I want to copy any non-empty field. For example if f18 is empty, I
> just want to copy f3 and f6
>
> >It sounds as if something like
>
> Is that the logic you coded below?
>
> > :nnoremap <buffer> <f4> :for idx in [3,18,6]<bar>let
> > val=split(getline('.'), '\t')[idx-1]<bar>if strlen(val)<bar>let
> > @+=val<bar>call input('Press enter
> > #'.idx)<bar>endif<bar>endfor<cr>

Then yes, depending on the latency with which your clipboard manager
detects that something has been put in the clipboard, you might even
be able to remove the "<bar>call input(...)" portion so you don't
have to press <enter> for each entry.

The mapping takes the current line, splits it on <tab>s, iterates
over the desired positions (3,18,6), pulling out that value and, if
it has a non-zero length, stuffs it in the system clipboard [then
currently waiting for you to hit <enter>, but as mentioned, you might
be able to take that bit out].

-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:

Post a Comment