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

7711Re: Probably the wrong forum to ask - double click highlight and quick search

Expand Messages
  • Nico Weber
    Jun 1, 2008
    • 0 Attachment
      Hi Rick,

      > I'm sure this is more of a general gvim type of newebie question and I
      > tried googling it but couldn't find hits on what I'm looking to do, so
      > figured I'd ask here...

      this list is for all questions related to vim on the mac, so asking
      here is perfectly fine. There's also vim_use for question about vim
      using vim in general. It has more subscribers, so you might get help
      faster over there for general vim questions.

      > I'm using MacVim and what I'd often like to do is highlight (often
      > with the mouse, but sometimes in visual mode as well) a region of
      > code. I know want to know the quickest way to search through the file
      > for what I have highlighted? The way I do it now seems too slow... I
      > end up doing a yank to clipboard and then do / (or ?) and ctrl-R and
      > then " to paste the text and search for it. I guess the command line
      > part isn't that bad but if I'm scrolling over a large file with the
      > mouse I often find it quick and easy to just double-click on a word to
      > highlight with the mouse. It would nice if I could then quickly search
      > from what I have highlighted.

      Short answer: Hit ⌘E to search for the text that is currently
      highlighted. This copies the currently highlighted text to the "search
      pasteboard". You can now hit ⌘G in all applications to search for
      this text. This is a Mac OS X feature and works in all apps (e.g. you
      could highlight text in MacVim, hit ⌘E, then switch to Safari and hit
      ⌘G to search for the text you had highlighted in MacVim). ⌘E is
      probably what you want.

      Long answer: You could add a mapping for your current approach:

      map <F3> y/<C-r>"<CR>

      Then you could hit F3 to search for the currently highlighted text
      (this won't use the system find pasteboard).

      Even better, you can simply hit * to search for the word under the
      cursor. This requires that the cursor is on the word you want to
      search for, and you say that you're using the mouse. It is often
      faster to navigate with the keyboard, so in cases where you're using
      the keyboard anyways, * might be a nice option.

      Finally, when you're browsing code, you probably want to search for an
      identifier to see where it is defined. In this cases, read about ctags
      or cscope and <C-]>, this is much more efficient to look up
      definitions (and with cscope, you can even look for all uses of a
      function, all functions called by a function, etc. -- at least if your
      programming language is supported by cscope).

      You received this message from the "vim_mac" maillist.
      For more information, visit http://www.vim.org/maillist.php
    • Show all 3 messages in this topic