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

lowercase next word

Expand Messages
  • Alessandro Ferrucci
    Hello, I would like to know if there is a command to lowercase the entire next word following the cursor.. example: ACCESSION NUMBER (the cursor would be under
    Message 1 of 7 , Jan 3, 2006
    • 0 Attachment
      Hello,

      I would like to know if there is a command to lowercase the entire next
      word following the cursor..


      example: ACCESSION NUMBER (the cursor would be under the N in NUMBER or in
      the space between ACCESSION and NUMBER)

      is there a command for that?

      Thanks
      ~Ale
    • James Vega
      ... guw ... HTH, James -- GPG Key: 1024D/61326D40 2003-09-02 James Vega
      Message 2 of 7 , Jan 3, 2006
      • 0 Attachment
        On Tue, Jan 03, 2006 at 01:07:11PM -0500, Alessandro Ferrucci wrote:
        > Hello,
        >
        > I would like to know if there is a command to lowercase the entire next
        > word following the cursor..

        guw

        :he case Explains various methods of changing the case of text.

        HTH,

        James
        --
        GPG Key: 1024D/61326D40 2003-09-02 James Vega <jamessan@...>
      • Tim Chase
        ... If it s on the space between them, then you can use wguw This can be mapped, if you re doing it frequently, in which case, you might want to map something
        Message 3 of 7 , Jan 3, 2006
        • 0 Attachment
          > I would like to know if there is a command to lowercase the
          > entire next word following the cursor..
          >
          > example: ACCESSION NUMBER (the cursor would be under the N in
          > NUMBER or in the space between ACCESSION and NUMBER)


          If it's on the space between them, then you can use

          wguw

          This can be mapped, if you're doing it frequently, in which case,
          you might want to map something like

          nnoremap <f4> wguw

          which will do it wherever you are in the 1st word or the space
          between them. The do have the side effect of moving the cursor
          to the beginning of the 2nd word, if that makes a difference.

          If you've got a lot of them to do, and they're always the 2nd
          word on a line, you might want to try

          :%s/\<\(\u\{2,}\s\+\)\(\u\{2,}\)\>/\1\L\2/g

          or

          :%s/\<\(\u\+\s\+\)\(\u\+\)\>/\1\L\2/g

          which will look for any pair of uppercase words back-to-back, and
          lowercase the second one. In those replacements, that's
          "backslash one backslash capital-ell backslash two". The first
          form requires that each word be at least two characters long, the
          second form requires only one upper-case letter per word.

          For more info, see

          :help gu
          :help /\u
          :help sub-replace-special

          which will detail some of what's going on in those.

          If you have any questions, here's the place to ask :)

          -tim
        • Gerald Lai
          ... If the normal mode cursor was on M of NUMBER , doing guw would produce NUmber . In order to get the whole word to change case, do guiw instead. See
          Message 4 of 7 , Jan 3, 2006
          • 0 Attachment
            On Tue, 3 Jan 2006, Tim Chase wrote:

            >> I would like to know if there is a command to lowercase the
            >> entire next word following the cursor..
            >>
            >> example: ACCESSION NUMBER (the cursor would be under the N in
            >> NUMBER or in the space between ACCESSION and NUMBER)
            >
            >
            > If it's on the space between them, then you can use
            >
            > wguw

            If the normal mode cursor was on "M" of "NUMBER", doing 'guw' would
            produce "NUmber". In order to get the whole word to change case, do
            'guiw' instead. See ":help iw" & ":help iW".

            Here are some mappings that would change the case of words "touching"
            the cursor (character of word is either under normal cursor or next to
            insert cursor). Cursor position maintained after case change. Replace
            mode friendly.

            " <F8> toggle case; <S-F8> uppercase; <C-F8> first letter uppercase,
            " lowercase for others
            nmap <F8> mzg~iw`z
            nmap <S-F8> mzgUiw`z
            nmap <C-F8> mzguiw~`z
            inoremap <F8> <Esc>gi_<Esc>mzi<S-Right><C-o>b<C-o>g~iw<C-o>`z<Del>
            inoremap <S-F8> <Esc>gi_<Esc>mzi<S-Right><C-o>b<C-o>gUiw<C-o>`z<Del>
            inoremap <C-F8> <Esc>gi_<Esc>mzi<S-Right><C-o>b<C-o>guiw<C-o>`z<Del><Esc>gew~gi

            Hope this helps.
            --
            Gerald
          • Tim Chase
            ... Note, however that it s wguw , not guw . The OP asked how to lowercase the *first full word after* the cursor: ACCESSION NUMBER ^^^^^^^^^^XXXXXX In the
            Message 5 of 7 , Jan 4, 2006
            • 0 Attachment
              >>> I would like to know if there is a command to lowercase
              >>> the entire next word following the cursor..
              >>>
              >>> example: ACCESSION NUMBER (the cursor would be under the N
              >>> in NUMBER or in the space between ACCESSION and NUMBER)
              >>
              >> If it's on the space between them, then you can use
              >>
              >> wguw
              >
              > If the normal mode cursor was on "M" of "NUMBER", doing 'guw'
              > would produce "NUmber".

              Note, however that it's "wguw", not "guw". The OP asked how to
              lowercase the *first full word after* the cursor:

              ACCESSION NUMBER
              ^^^^^^^^^^XXXXXX

              In the example given by the OP, the word NUMBER should be
              lowercased whenever the cursor is in a location marked by the
              "^". If, per your example, the cursor is on the "M" of "NUMBER",
              you'd have to have a word following "NUMBER" to pose the question:

              ACCESSION NUMBER FOO
              ^^^^^^^XXX

              in which case it sounds like the OP would want "FOO" (the "entire
              next word following the cursor") to be lowercased if the cursor
              starts in the region marked with "^" characters.

              In both cases "wguw" lowercases the entire word following the cursor.

              But yes, if you are within a word, using "guiw" will lowercase
              the entire word in which the cursor is located.

              -tim
            • Alessandro Ferrucci
              Wow, thank you so much for everyone s response, it s given me lots of insight. I have to say that you guys form the best list I ve ever been on, congrats and
              Message 6 of 7 , Jan 4, 2006
              • 0 Attachment
                Wow, thank you so much for everyone's response, it's given me lots of
                insight.

                I have to say that you guys form the best list I've ever been on, congrats
                and thank you very much for the help.

                ~Alessandro Ferrucci

                >>>> I would like to know if there is a command to lowercase
                >>>> the entire next word following the cursor..
                >>>>
                >>>> example: ACCESSION NUMBER (the cursor would be under the N
                >>>> in NUMBER or in the space between ACCESSION and NUMBER)
                >>>
                >>> If it's on the space between them, then you can use
                >>>
                >>> wguw
                >>
                >> If the normal mode cursor was on "M" of "NUMBER", doing 'guw'
                >> would produce "NUmber".
                >
                > Note, however that it's "wguw", not "guw". The OP asked how to
                > lowercase the *first full word after* the cursor:
                >
                > ACCESSION NUMBER
                > ^^^^^^^^^^XXXXXX
                >
                > In the example given by the OP, the word NUMBER should be
                > lowercased whenever the cursor is in a location marked by the
                > "^". If, per your example, the cursor is on the "M" of "NUMBER",
                > you'd have to have a word following "NUMBER" to pose the question:
                >
                > ACCESSION NUMBER FOO
                > ^^^^^^^XXX
                >
                > in which case it sounds like the OP would want "FOO" (the "entire
                > next word following the cursor") to be lowercased if the cursor
                > starts in the region marked with "^" characters.
                >
                > In both cases "wguw" lowercases the entire word following the cursor.
                >
                > But yes, if you are within a word, using "guiw" will lowercase
                > the entire word in which the cursor is located.
                >
                > -tim
                >
                >
                >
                >
                >
                >
                >
              • Gerald Lai
                ... Yes, the OP did want the next full word after the cursor. Some time ago, I also wanted similar functionality of toggling cases of words. In addition, I
                Message 7 of 7 , Jan 4, 2006
                • 0 Attachment
                  On Wed, 4 Jan 2006, Tim Chase wrote:

                  >>>> I would like to know if there is a command to lowercase
                  >>>> the entire next word following the cursor..
                  >>>>
                  >>>> example: ACCESSION NUMBER (the cursor would be under the N
                  >>>> in NUMBER or in the space between ACCESSION and NUMBER)
                  >>>
                  >>> If it's on the space between them, then you can use
                  >>>
                  >>> wguw
                  >>
                  >> If the normal mode cursor was on "M" of "NUMBER", doing 'guw'
                  >> would produce "NUmber".
                  >
                  > Note, however that it's "wguw", not "guw". The OP asked how to
                  > lowercase the *first full word after* the cursor:
                  >
                  > ACCESSION NUMBER
                  > ^^^^^^^^^^XXXXXX
                  >
                  > In the example given by the OP, the word NUMBER should be
                  > lowercased whenever the cursor is in a location marked by the
                  > "^". If, per your example, the cursor is on the "M" of "NUMBER",
                  > you'd have to have a word following "NUMBER" to pose the question:
                  >
                  > ACCESSION NUMBER FOO
                  > ^^^^^^^XXX
                  >
                  > in which case it sounds like the OP would want "FOO" (the "entire
                  > next word following the cursor") to be lowercased if the cursor
                  > starts in the region marked with "^" characters.
                  >
                  > In both cases "wguw" lowercases the entire word following the cursor.
                  >
                  > But yes, if you are within a word, using "guiw" will lowercase
                  > the entire word in which the cursor is located.

                  Yes, the OP did want the next full word after the cursor.

                  Some time ago, I also wanted similar functionality of toggling cases
                  of words. In addition, I wanted one that was intuitive and would work
                  everywhere within the buffer all the time. And then I would keymap
                  that keystroke to make a one-key wonder. I believe I tried
                  combinations such as 'wguw' but just to point out, 'wguw' breaks down
                  for the last word of the buffer because there is no next full word.

                  The intuitive way IMHO that I came up with does something like this:

                  ACCESSION NUMBER FOO
                  ^^^^^^^^^*^^^^^^*XXX*^^^

                  where cursor on: ^ would change the case of the obvious word
                  * changes nothing for normal cursor, changes case for
                  insert cursor next to word (e.g. on first *,
                  NUMBER changes case if insert cursor is before N)
                  X changes nothing for both normal & insert type cursors

                  --
                  Gerald
                Your message has been successfully submitted and would be delivered to recipients shortly.