Loading ...
Sorry, an error occurred while loading the content.

14082Re: how to copy into system clipboard

Expand Messages
  • Tony Mechelynck
    Nov 23, 2013
      On Wednesday, November 20, 2013 6:44:11 PM UTC+1, Bee wrote:
      > On Wednesday, November 20, 2013 12:43:22 AM UTC-8, LittleQ wrote:
      > > it should be ‘single quote’, so it’s  ‘<, ‘> not  `<, `>
      > I know '< works for lines, but my attempt to use `< is to select a character range.
      > :help `<
      > '< `< To the first line or character of the last selected Visual area in the current buffer.
      > Is there a way to write the CHARACTER selection to stdout? for use by pbcopy
      > Bill

      Ex-commands always act linewise on the range of lines you type between the : and the command name (or before the command name in a script).

      To act on a visual selection you could type "+y in Visual mode, but using :normal would defeat this because hitting : in Visual mode goes out of Visual and places you in command-line mode with :'<,'> before the cursor, so that the ex-command you're about to type will act linewise on the just unselected Visual selection. You can act characterwise on an object or a motion by including the object or motion command after "+y in the operand of :normal, e.g.:

      :normal "+yW

      will yank to the clipboard (i.e. "copy") the WORD at the cursor with no surrounding space. (Similarly, just :normal yW would yank it to the "unnamed" register.) Then you would have to find out how to put that out to your pbcopy command. One possibility (in a script) would be

      normal yW
      $,$w !pbcopy

      remembering that the $put command will add the register linewise after the last line (thus creating a new line) so the $ line number in the last two commands above will be one more than in the $put command. I haven't checked where the cursor ends up at the end of this snippet.

      The above snippet is valid because a WORD will never span more than one line. How to make it work for a multi-line characterwise yank is left as an exercise to the reader. (Hint: see "help line()" and ":help :execute")

      Best regards,
      As a general rule of thumb, never trust anybody who's been in therapy
      for more than 15 percent of their life span. The words "I am sorry" and "I
      am wrong" will have totally disappeared from their vocabulary. They will stab
      you, shoot you, break things in your apartment, say horrible things to your
      friends and family, and then justify this abhorrent behavior by saying:
      "Sure, I put your dog in the microwave. But I feel *better* for doing it."
      -- Bruce Feirstein, "Nice Guys Sleep Alone"

      You received this message from the "vim_mac" 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_mac" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_mac+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Show all 16 messages in this topic