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

Re: operating up to camelcase

Expand Messages
  • Benji Fisher
    ... Another option is to use an :omap such as ... If you only want this in a few file types, make it ... and put it in your ftplugin file. Then ceCorrect
    Message 1 of 8 , Jun 2, 2002
    • 0 Attachment
      Paul Brannan wrote:
      >
      > On Fri, May 31, 2002 at 12:00:01PM -0700, Eric Winger wrote:
      > > This works for delete. But for change, how do you stop recording while
      > > in insert mode? If you hit ESC, then you record that too.
      >
      > 1) Use Ctrl-O:
      > qcc/\([A-Z]\|\>\)<Ctrl-O>q
      >
      > Note that I've changed the macro so it will only delete to the end of
      > a word, and not beyond it.
      >
      > 2) Instead of a macro, you can use a map in your .vimrc file.
      >
      > :map ,c c/\([A-Z]\\|\>\)<CR>
      >
      > Note the extra \ in front of the |.
      >
      > Paul

      Another option is to use an :omap such as

      :omap e v/\a\u\\|\a\><CR>

      If you only want this in a few file types, make it

      :omap <buffer> e v/\a\u\\|\a\><CR>

      and put it in your ftplugin file. Then

      ceCorrect<Esc>

      should change

      myIncorrectName

      (starting with the cursor on the "I") to

      myCorrectName

      as desired.

      Explanation:

      :omap e " map that takes effect when an Operator is pending
      v " make it inclusive (exclusive by default)
      / " search for a pattern
      \a\u " an alphabetic character followed by an uppercase character
      \\| " one \ eaten by the :omap command; \| separates two patterns
      \a\> " an alphabetic character followed by a word boundary
      <CR> " finish the search command

      You might prefer to use \w or \k rather than \a. I admit this is a little
      complicated: I wanted to make sure it works if the word is followed by a
      space or by an EOL character, and this is the simplest I could make it. It
      also might annoy you if you have the 'hlsearch' option set.

      HTH --Benji Fisher
    • Eric Winger
      Thx for the responses everyone.. I m a little slow to respond & some of the below is to me (newbie vim mer) somewhat perplexing. ... I m not sure what you mean
      Message 2 of 8 , Jun 3, 2002
      • 0 Attachment
        Thx for the responses everyone.. I'm a little slow to respond & some of
        the below is to me (newbie vim'mer) somewhat perplexing.

        Benji Fisher wrote:

        >Paul Brannan wrote:
        >
        >>On Fri, May 31, 2002 at 12:00:01PM -0700, Eric Winger wrote:
        >>
        >>>This works for delete. But for change, how do you stop recording while
        >>>in insert mode? If you hit ESC, then you record that too.
        >>>
        >>1) Use Ctrl-O:
        >> qcc/\([A-Z]\|\>\)<Ctrl-O>q
        >>
        >> Note that I've changed the macro so it will only delete to the end of
        >> a word, and not beyond it.
        >>
        >>2) Instead of a macro, you can use a map in your .vimrc file.
        >>
        >> :map ,c c/\([A-Z]\\|\>\)<CR>
        >>
        >> Note the extra \ in front of the |.
        >>
        >>Paul
        >>
        >
        > Another option is to use an :omap such as
        >
        >:omap e v/\a\u\\|\a\><CR>
        >
        >
        >
        >If you only want this in a few file types, make it
        >
        >:omap <buffer> e v/\a\u\\|\a\><CR>
        >
        >and put it in your ftplugin file. Then
        >
        >ceCorrect<Esc>
        >
        >should change
        >
        >myIncorrectName
        >
        >(starting with the cursor on the "I") to
        >
        >myCorrectName
        >
        >as desired.
        >
        > Explanation:
        >
        >:omap e " map that takes effect when an Operator is pending
        >v " make it inclusive (exclusive by default)
        >
        I'm not sure what you mean be inclusive & exclusive in this context.

        >
        >/ " search for a pattern
        >\a\u " an alphabetic character followed by an uppercase character
        >\\| " one \ eaten by the :omap command; \| separates two patterns
        >
        'eaten' by :omap ? You lost me.

        is the \| equivalent logically to an or? So that I'm saying "look for a
        lower case char followed by an uppercase char OR look for uppercase
        followed by word boundary.

        >
        >\a\> " an alphabetic character followed by a word boundary
        >
        >
        ><CR> " finish the search command
        >
        >You might prefer to use \w or \k rather than \a. I admit this is a little
        >complicated: I wanted to make sure it works if the word is followed by a
        >space or by an EOL character, and this is the simplest I could make it. It
        >also might annoy you if you have the 'hlsearch' option set.
        >

        the :omap changes seem to go away when I quit editing the file. Is there
        a way to make omap changes presistent & re-editable later?

        >
        >
        >HTH --Benji Fisher
        >
      • Benji Fisher
        ... and you may want to read more of the same file (motion.txt) for context. ... In various contexts (strings, right-hand side of maps, ...) special
        Message 3 of 8 , Jun 3, 2002
        • 0 Attachment
          On Monday, June 3, 2002, at 02:25 PM, Eric Winger wrote:

          > Thx for the responses everyone.. I'm a little slow to respond & some of
          > the below is to me (newbie vim'mer) somewhat perplexing.
          >
          > Benji Fisher wrote:
          >
          >> Another option is to use an :omap such as
          >>
          >> :omap e v/\a\u\\|\a\><CR>
          >>
          >>
          >>
          >> If you only want this in a few file types, make it
          >>
          >> :omap <buffer> e v/\a\u\\|\a\><CR>
          >>
          >> and put it in your ftplugin file. Then
          >>
          >> ceCorrect<Esc>
          >>
          >> should change
          >>
          >> myIncorrectName
          >>
          >> (starting with the cursor on the "I") to
          >>
          >> myCorrectName
          >>
          >> as desired.
          >>
          >> Explanation:
          >>
          >> :omap e " map that takes effect when an Operator is pending
          >> v " make it inclusive (exclusive by default)
          >>
          > I'm not sure what you mean be inclusive & exclusive in this context.

          :help inclusive
          :help o_v

          and you may want to read more of the same file (motion.txt) for context.

          >>
          >> / " search for a pattern
          >> \a\u " an alphabetic character followed by an uppercase character
          >> \\| " one \ eaten by the :omap command; \| separates two patterns
          >>
          > 'eaten' by :omap ? You lost me.

          In various contexts (strings, right-hand side of maps, ...) special
          characters are escaped by \ characters. Here, \\ in the right-hand side
          of the :omap command is treated as an escaped \, so \| ends up as part
          of the pattern.

          > is the \| equivalent logically to an or? So that I'm saying "look for a
          > lower case char followed by an uppercase char OR look for uppercase
          > followed by word boundary.

          Yes. See

          :help /\|

          for a full explanation.

          >>
          >> \a\> " an alphabetic character followed by a word boundary
          >>
          >>
          >> <CR> " finish the search command
          >>
          >> You might prefer to use \w or \k rather than \a. I admit this is a
          >> little
          >> complicated: I wanted to make sure it works if the word is followed
          >> by a
          >> space or by an EOL character, and this is the simplest I could make
          >> it. It
          >> also might annoy you if you have the 'hlsearch' option set.
          >>
          >
          > the :omap changes seem to go away when I quit editing the file. Is
          > there a way to make omap changes presistent & re-editable later?

          It should only go away when you quit vim. See

          :help usr_05.txt

          in the users' manual for using it each time you start vim.

          HTH --Benji Fisher
        Your message has been successfully submitted and would be delivered to recipients shortly.