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

operating up to camelcase

Expand Messages
  • Eric Winger
    Hi! I m new to the list, so I m hoping I selected the right mailling list for this question. I m looking for a quick way to delete/change/whatever up to a
    Message 1 of 8 , May 31, 2002
      Hi! I'm new to the list, so I'm hoping I selected the right mailling
      list for this question.

      I'm looking for a quick way to delete/change/whatever up to a change in
      camelcase.

      Example:

      myIncorrectName

      should be:

      myCorrectName

      I know I can do
      ctI or dtI

      but I'd really rather just have it change up to the next case change.

      Any ideas?

      thx

      Eric
    • Ingo Blechschmidt
      ... I would use c/[A-Z] when the cursor is under the I . I think, there is a more elegant solution, but if you make a macro it is fast enough: qcc/[A-Z] q
      Message 2 of 8 , May 31, 2002
        On Fri, May 31, 2002 at 10:17:42AM -0700, Eric Winger wrote:
        > I'm looking for a quick way to delete/change/whatever up to a change in
        > camelcase.
        >
        > Example:
        >
        > myIncorrectName
        >
        > should be:
        >
        > myCorrectName

        I would use c/[A-Z] when the cursor is under the 'I'.

        I think, there is a more elegant solution, but if you make a macro
        it is fast enough:

        qcc/[A-Z]
        q

        Then a simple @c is sufficient.


        Regards,

        Ingo

        --
        Ingo Blechschmidt Time sharing - the use of many people
        mailto:iblech@... by the (Window$) computer. .~.
        tel:+49.821.882955 Registered Linuxer #232173, see http:// /V\
        http://linide.sf.net/ counter.li.org/. LFS user #1055. /( )\
        host:iblech.dyndns.org finger/talk: iblech@... ^`~'^
        Call +49.821.6509763 to let my computer connect to the internet
      • Eric Winger
        ... 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.
        Message 3 of 8 , May 31, 2002
          Ingo Blechschmidt wrote:

          >On Fri, May 31, 2002 at 10:17:42AM -0700, Eric Winger wrote:
          >
          >>I'm looking for a quick way to delete/change/whatever up to a change in
          >>camelcase.
          >>
          >>Example:
          >>
          >>myIncorrectName
          >>
          >>should be:
          >>
          >>myCorrectName
          >>
          >
          >I would use c/[A-Z] when the cursor is under the 'I'.
          >
          >I think, there is a more elegant solution, but if you make a macro
          >it is fast enough:
          >
          >qcc/[A-Z]
          >q
          >
          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.

          >
          >Then a simple @c is sufficient.
          >
          >
          >Regards,
          >
          >Ingo
          >
        • Thomas S. Urban
          ... You can record the macro then modify it - in a new buffer do qcc/[A-Z] q ... Then visually select the portion you want to save (through ^M),
          Message 4 of 8 , May 31, 2002
            On Fri, May 31, 2002 at 12:00:01 -0700, Eric Winger sent 0.6K bytes:
            >
            >
            > Ingo Blechschmidt wrote:
            >
            > >On Fri, May 31, 2002 at 10:17:42AM -0700, Eric Winger wrote:
            > >
            > >>I'm looking for a quick way to delete/change/whatever up to a change in
            > >>camelcase.
            > >>
            > >>Example:
            > >>
            > >>myIncorrectName
            > >>
            > >>should be:
            > >>
            > >>myCorrectName
            > >>
            > >
            > >I would use c/[A-Z] when the cursor is under the 'I'.
            > >
            > >I think, there is a more elegant solution, but if you make a macro
            > >it is fast enough:
            > >
            > >qcc/[A-Z]
            > >q
            > >
            > 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.


            You can record the macro then modify it - in a new buffer do

            qcc/[A-Z]<Enter><Esc>q

            :new
            :0put c

            Then visually select the portion you want to save (through ^M), then

            "cy

            Now you've modified your macro. I do this alot since it's often easier
            to make a modifiction or correct a mistake like that than try to
            re-record it.

            Scott


            --
            Food for thought is no substitute for the real thing.
            -- Walt Kelly, "Potluck Pogo"
          • Paul Brannan
            ... 1) Use Ctrl-O: qcc/ ([A-Z] | ) 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
            Message 5 of 8 , May 31, 2002
              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
            • 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 6 of 8 , Jun 2 9:53 AM
                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 7 of 8 , Jun 3 11:25 AM
                  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 8 of 8 , Jun 3 12:32 PM
                    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.