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

how can I configure word highlighting in VIM ?

Expand Messages
  • Arup Rakshit
    Hi, I use vim to write my Ruby code. Say, I wrote a code as below : foo = 2 def meth(arg) puts arg end meth(foo) Now suppose, I defined **foo** in the line#4.
    Message 1 of 5 , Mar 29 2:09 PM
    • 0 Attachment
      Hi,

      I use vim to write my Ruby code. Say, I wrote a code as below :

      foo = 2
      def meth(arg)
      puts arg
      end

      meth(foo)

      Now suppose, I defined **foo** in the line#4. Now I am calling the method with **foo** as an argument, from line #20. Now suppose I am selecting the word, **foo** using command **viw**. Now I want all `foo` to be highlighted. If this can be done, it would help me in lots of scenarios.

      --
      --
      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@....
      For more options, visit https://groups.google.com/d/optout.
    • John Beckett
      ... If you mean by searching, I suggest starting here: http://vim.wikia.com/wiki/Searching See what it says (you know about * ?), and scan down to the
      Message 2 of 5 , Mar 29 7:42 PM
      • 0 Attachment
        Arup Rakshit wrote:
        > Subject: how can I configure word highlighting in VIM ?

        If you mean by searching, I suggest starting here:

        http://vim.wikia.com/wiki/Searching

        See what it says (you know about "*"?), and scan down to the
        "Highlighting search matches" link near the bottom. There are
        also some search-without-moving ideas there somewhere.

        To just highlight, see:

        http://vim.wikia.com/wiki/Highlight_multiple_words

        John


        --
        --
        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@....
        For more options, visit https://groups.google.com/d/optout.
      • Arup Rakshit
        I found this feature, long back in Notepad++. In that editor, if you select any word, it will highlight all occurrence of that word. It sometime helps to
        Message 3 of 5 , Mar 29 11:26 PM
        • 0 Attachment
          I found this feature, long back in Notepad++. In that editor, if you select any word, it will highlight all occurrence of that word. It sometime helps to verify if at the line# 100 any variable I am using, it will confirm, if that was defined previously or not.


          On Sun, Mar 30, 2014 at 8:12 AM, John Beckett <johnb.beckett@...> wrote:
          Arup Rakshit wrote:
          > Subject: how can I configure word highlighting in VIM ?

          If you mean by searching, I suggest starting here:

          http://vim.wikia.com/wiki/Searching

          See what it says (you know about "*"?), and scan down to the
          "Highlighting search matches" link near the bottom. There are
          also some search-without-moving ideas there somewhere.

          To just highlight, see:

          http://vim.wikia.com/wiki/Highlight_multiple_words

          John


          --
          --
          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 a topic in the Google Groups "vim_use" group.
          To unsubscribe from this topic, visit https://groups.google.com/d/topic/vim_use/hXcGlddeUbM/unsubscribe.
          To unsubscribe from this group and all its topics, send an email to vim_use+unsubscribe@....
          For more options, visit https://groups.google.com/d/optout.



          --
          *---------------------------------------------------------------*
          *Warm Regards,*

          *Arup Rakshit*
          *Software Engineer*



          --
          --
          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@....
          For more options, visit https://groups.google.com/d/optout.
        • tooth pik
          ... you did not respond to John s question: you know about * ?, and your re-query implies you don t if you navigate to the word you want highlighted, press *
          Message 4 of 5 , Mar 29 11:51 PM
          • 0 Attachment
            On Sun, Mar 30, 2014 at 11:56:50AM +0530, Arup Rakshit wrote:
            > I found this feature, long back in Notepad++. In that editor, if you select
            > any word, it will highlight all occurrence of that word. It sometime helps
            > to verify if at the line# 100 any variable I am using, it will confirm, if
            > that was defined previously or not.

            you did not respond to John's question: you know about "*"?, and your
            re-query implies you don't

            if you navigate to the word you want highlighted, press * , that word
            will be searched for, and by virtue of its now being in the @/ register,
            all occurrences of that word will now by default be highlighted, and you
            can re-search with n and N

            --
            _|_ _ __|_|_ ._ o|
            |_(_)(_)|_| ||_)||<
            |

            --
            --
            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@....
            For more options, visit https://groups.google.com/d/optout.
          • Jürgen Krämer
            [Text re-ordered; please don t top-post] Hi, ... you can put the following lines in a script file in your plugins directory: highlight default link CurrentWord
            Message 5 of 5 , Apr 1, 2014
            • 0 Attachment
              [Text re-ordered; please don't top-post]

              Hi,

              Arup Rakshit wrote:
              >
              > On Sun, Mar 30, 2014 at 8:12 AM, John Beckett <johnb.beckett@... <mailto:johnb.beckett@...>> wrote:
              >>
              >> Arup Rakshit wrote:
              >> > Subject: how can I configure word highlighting in VIM ?
              >>
              >> If you mean by searching, I suggest starting here:
              >>
              >> http://vim.wikia.com/wiki/Searching
              >>
              >> See what it says (you know about "*"?), and scan down to the
              >> "Highlighting search matches" link near the bottom. There are
              >> also some search-without-moving ideas there somewhere.
              >>
              >> To just highlight, see:
              >>
              >> http://vim.wikia.com/wiki/Highlight_multiple_words
              >
              > I found this feature, long back in Notepad++. In that editor, if you
              > select any word, it will highlight all occurrence of that word. It
              > sometime helps to verify if at the line# 100 any variable I am using,
              > it will confirm, if that was defined previously or not.

              you can put the following lines in a script file in your plugins directory:

              highlight default link CurrentWord IncSearch

              function! s:HighlightCurrentWord(on)
              if a:on
              augroup HighlightCurrentWord
              au CursorMoved,CursorMovedI * exe 'match CurrentWord /\<' . escape(expand('<cword>'), '\/.*$^~[]') . '\>/'
              augroup END
              else
              augroup HighlightCurrentWord
              au!
              match NONE
              augroup END
              endif
              endfunction

              command! -bang HiCurWord call s:HighlightCurrentWord(expand('<bang>') != '!')

              Then, if you execute ":HiCurWord", all occurences of the word under the
              cursor will get highlighted. If you move the cursor to a different word,
              the new word will get highlighted.

              ":HiCurWord!" switches highlighting off.

              If you want to save some key strokes, define mappings like

              nnoremap <F12> :HiCurWord<cr>
              nnoremap <S-F12> :HiCurWord!<cr>

              Regards,
              Jürgen

              --
              Sometimes I think the surest sign that intelligent life exists elsewhere
              in the universe is that none of it has tried to contact us. (Calvin)

              --
              --
              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@....
              For more options, visit https://groups.google.com/d/optout.
            Your message has been successfully submitted and would be delivered to recipients shortly.