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

Re: Manipulate selected text

Expand Messages
  • Benjamin ter Kuile
    After using the good old terminal vim for a while again I will give it another shot. Thanks for all the suggestions/workarounds. The many tips to work around
    Message 1 of 9 , Nov 15, 2011
    • 0 Attachment
      After using the good old terminal vim for a while again I will give it another shot. Thanks for all the suggestions/workarounds. The many tips to work around the problems shows how versatile vim is. For me there were two tips that made it work for me, so here the summary:

      typing ctrl-g when text is selected makes it possible to do actions on the selected text (not replacing it) (thanks to Kyle Lippincott)
      And my final solution given by Tony Mechelynck, add the following to your ~/.gvimrc file:
         set selectmode=mouse,key
         set mousemodel=popup
         set keymodel=startsel
         set selection=inclusive
      This returns the for me expected behaviour. 

      Thanks for the help!

      On 7 October 2011 02:33, Carl Jacobsen <carl@...> wrote:
      On Thu, 29 Sep 2011, Andrew Stewart wrote:

      On Sep 29, 4:07 pm, bterkuile <bterku...@...> wrote:
      How can I fix this? Or is there even a better way of doing this (meaning typing commands, not just replacing text). I cannot find the solution on google.

      Yes, use ranges.  Turn on line numbers with `:set number`, then to substitute (for example) over lines 4 to 6 use `:4,6s/foo/bar/g`.  See `:help range` for other line numbers you can use, such as % (the whole file), $ (the last line in the file), and so on.  You can even use offsets.

      Another similar approach (and what I usually use) is with marks; set a mark at one end of the range, then maneuver to the other end of the range and set another mark (e.g. I'll often mark the top line using "ma" and the bottom line with "mb"), then use:

             :'a,'bs/foo/bar/g

      I suppose it's more keystrokes than using "v" for visual mode, but it has worked since long before Vim arrived on the scene, and it isn't subject to the changes in behavior depending on various options that this thread seems to be finding. See ":help mark-motions" for more.

      Cheers,
      Carl


      --
      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 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
    Your message has been successfully submitted and would be delivered to recipients shortly.