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

Searching for single character without anything around it , possible ?

Expand Messages
  • Aaron Lewis
    ... Hash: SHA1 Hi, I ve remembered that some implementations of RegExp has a b sign , e.g bi b means an character `i without anything around it , does
    Message 1 of 2 , Jul 31 1:34 AM
    • 0 Attachment
      -----BEGIN PGP SIGNED MESSAGE-----
      Hash: SHA1

      Hi,
      I've remembered that some implementations of RegExp has a '\b' sign ,
      e.g \bi\b means an character `i' without anything around it , does vim
      support it ?

      :help regular-expression seems to have that expression , but no much
      documents about it.

      Consider this: int i = 0 ; i < numOfServ ; i ++
      And i'd like to replace the single `i' with j , so i tried s/\bi\b/j/g
      , not working ? Or maybe something else , anyone could help ?

      Thanks in advance !

      - --
      Best Regards,
      Aaron Lewis - PGP: 0x4A6D32A0
      FingerPrint EA63 26B2 6C52 72EA A4A5 EB6B BDFE 35B0 4A6D 32A0
      irc: A4R0NL3WI5 on freenode
      -----BEGIN PGP SIGNATURE-----
      Version: GnuPG v2.0.16 (GNU/Linux)
      Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

      iEYEARECAAYFAkxT3/wACgkQvf41sEptMqB/zACgw5o+ddyrH9so31APTpkm6z/5
      nmoAoKY1g8RJiqnscx/Gd9cMfWGFJnWr
      =UsVU
      -----END PGP SIGNATURE-----

      --
      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
    • Tony Mechelynck
      ... In Vim regexps, b means a backspace character: probably not what you want; but means end-of-word so / / would find the
      Message 2 of 2 , Jul 31 3:02 AM
      • 0 Attachment
        On 31/07/10 10:34, Aaron Lewis wrote:
        > -----BEGIN PGP SIGNED MESSAGE-----
        > Hash: SHA1
        >
        > Hi,
        > I've remembered that some implementations of RegExp has a '\b' sign ,
        > e.g \bi\b means an character `i' without anything around it , does vim
        > support it ?
        >
        > :help regular-expression seems to have that expression , but no much
        > documents about it.
        >
        > Consider this: int i = 0 ; i< numOfServ ; i ++
        > And i'd like to replace the single `i' with j , so i tried s/\bi\b/j/g
        > , not working ? Or maybe something else , anyone could help ?
        >
        > Thanks in advance !

        In Vim regexps, \b means a backspace character: probably not what you
        want; but \< means start-of-word and \> means end-of-word so /\<i\>/
        would find the letter i (which is in 'iskeyword') with no other
        'iskeyword' character next to it. Before it could be the start of the
        line, or a space, a tab, a comma, a parenthesis, etc., or anything not
        in 'iskeyword'; after it could be the end of the line, a space, etc.

        If you want i alone on its line, then /^i$/ would match it ( ^ is
        begin-of-line and $ is end-of-line). If you want either a space, tab, or
        begin-of-line before, and a space, tab, or end-of-line after, then you
        could match with /\%(^\|\s\)\zsi\ze\%(\s\|$)/ The latter can be
        simplified to /\_s\zsi\ze\_s/ if your "lone i" can be neither the first
        character of the file nor the last character on a file with no
        end-of-line on its last line.

        See :help pattern-overview -- the list continues until the next line of
        equal signs across the page.


        Best regards,
        Tony.
        --
        It is illegal to rob a bank and then shoot at the bank teller with a water
        pistol.
        [real standing law in Louisana, United States of America]

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