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

Re: Search characters under cursor

Expand Messages
  • Christian Brabandt
    ... I personally would use something like this: nnoremap :norm! ayl :let @/=escape(@a, .~ ) nnoremap :norm! ayl :let
    Message 1 of 4 , Jul 1, 2009
    View Source
    • 0 Attachment
      On Wed, July 1, 2009 5:20 pm, Tim Chase wrote:
      > You might try this pair of mappings:
      >
      > nnoremap <f4> :let @/=escape(getline('.')[col('.')-1],
      > '.~\\')<cr><right>
      >
      > nnoremap <f5> :let @/.=escape(getline('.')[col('.')-1],
      > '.~\\')<cr><right>
      >

      I personally would use something like this:

      nnoremap <f4> :norm! "ayl<cr>:let @/=escape(@a, '.~\\')<cr><right>
      nnoremap <f5> :norm! "ayl<cr>:let @/.=escape(@a, '.~\\')<cr><right>

      The reason is, that col('.')-1 has problems with multibyte chars and
      will return only the first byte of the char under the cursor.

      But this has the disadvantage of cluttering your "a register.

      regards,
      Christian
      --
      :wq!


      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • rpmcmurphy
      Thanks guys. Both methods work great. Am not editing multibyte so I ll save my a reg. ... --~--~---------~--~----~------------~-------~--~----~ You received
      Message 2 of 4 , Jul 1, 2009
      View Source
      • 0 Attachment
        Thanks guys. Both methods work great. Am not editing multibyte so I'll
        save my "a reg.


        On Jul 1, 8:48 pm, "Christian Brabandt" <cbli...@...> wrote:
        > On Wed, July 1, 2009 5:20 pm, Tim Chase wrote:
        > > You might try this pair of mappings:
        >
        > > nnoremap <f4> :let @/=escape(getline('.')[col('.')-1],
        > > '.~\\')<cr><right>
        >
        > > nnoremap <f5> :let @/.=escape(getline('.')[col('.')-1],
        > > '.~\\')<cr><right>
        >
        > I personally would use something like this:
        >
        > nnoremap <f4> :norm! "ayl<cr>:let @/=escape(@a, '.~\\')<cr><right>
        > nnoremap <f5> :norm! "ayl<cr>:let @/.=escape(@a, '.~\\')<cr><right>
        >
        > The reason is, that col('.')-1 has problems with multibyte chars and
        > will return only the first byte of the char under the cursor.
        >
        > But this has the disadvantage of cluttering your "a register.
        >
        > regards,
        > Christian
        > --
        > :wq!
        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_use" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      Your message has been successfully submitted and would be delivered to recipients shortly.