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

how to repl. word under the cursor with foowordbar?

Expand Messages
  • M K Saravanan
    hi, How to replace a word under the cursor (say: junk) with another foojunkbar? when i am reading a paragraph, some of the word i want to change as
    Message 1 of 6 , Apr 2 7:29 AM
    View Source
    • 0 Attachment
      hi,

      How to replace a word under the cursor (say: junk) with another
      foojunkbar? when i am reading a paragraph, some of the word i want to
      change as \texttt{word}. i.e. the word under the cursor should come
      inside { }. how to do that in vim?

      -- mks --
    • Thomas Köhler
      ... yiwi texttt{ ea} (which you might want to map on a shorter key). yiw yank inner word. This puts the cursor on the first
      Message 2 of 6 , Apr 2 7:49 AM
      View Source
      • 0 Attachment
        M K Saravanan wrote [020402 17:36]:
        > hi,
        >
        > How to replace a word under the cursor (say: junk) with another
        > foojunkbar? when i am reading a paragraph, some of the word i
        > want to change as \texttt{word}. i.e. the word under the
        > cursor should come inside { }. how to do that in vim?

        yiwi\texttt{<ESC>ea}<ESC>

        (which you might want to map on a shorter key).

        yiw yank inner word. This puts the cursor
        on the first character in the word,
        that's why I use this little trick. If
        you don't want to fiddle around with
        the unnamed register, use some funny
        viw game instead...
        i\texttt{<ESC> insert \texttt{ and get back to normal
        mode
        e go to end of word
        a}<ESC> append } and go back to normal mode.

        Now map it to a key, say F2:
        :nmap <F2> yiwi\texttt{<ESC>ea}<ESC>

        Ciao,
        Thomas

        --
        Thomas Köhler Email: jean-luc@... | LCARS - Linux
        <>< WWW: http://jeanluc-picard.de | for Computers
        IRC: jeanluc | on All Real
        PGP public key available from Homepage! | Starships
      • HALIM,SALMAN (HP-NewJersey,ex2)
        perhaps i m missing something, but why mess up the yank register by hitting yiw? why not just use b ? (is it because the cursor might be at the first
        Message 3 of 6 , Apr 2 8:08 AM
        View Source
        • 0 Attachment
          perhaps i'm missing something, but why mess up the yank register by hitting
          yiw? why not just use 'b'? (is it because the cursor might be at the first
          character of the word?)

          i think the 'viw' version is:

          viwo<esc> or <c-v>iwo<esc>

          (character-wise or block-wise; either one works.)

          salman.

          -----Original Message-----
          From: Thomas Köhler [mailto:jean-luc@...]
          Sent: Tuesday, April 02, 2002 10:49 AM
          To: vim@...
          Subject: Re: how to repl. word under the cursor with foowordbar?


          M K Saravanan wrote [020402 17:36]:
          > hi,
          >
          > How to replace a word under the cursor (say: junk) with another
          > foojunkbar? when i am reading a paragraph, some of the word i
          > want to change as \texttt{word}. i.e. the word under the
          > cursor should come inside { }. how to do that in vim?

          yiwi\texttt{<ESC>ea}<ESC>

          (which you might want to map on a shorter key).

          yiw yank inner word. This puts the cursor
          on the first character in the word,
          that's why I use this little trick. If
          you don't want to fiddle around with
          the unnamed register, use some funny
          viw game instead...
          i\texttt{<ESC> insert \texttt{ and get back to normal
          mode
          e go to end of word
          a}<ESC> append } and go back to normal mode.

          Now map it to a key, say F2:
          :nmap <F2> yiwi\texttt{<ESC>ea}<ESC>

          Ciao,
          Thomas

          --
          Thomas Köhler Email: jean-luc@... | LCARS - Linux
          <>< WWW: http://jeanluc-picard.de | for Computers
          IRC: jeanluc | on All Real
          PGP public key available from Homepage! | Starships
        • Charles E. Campbell
          ... That would be the major problem. Also, depending on options, a b taken with the cursor at the first column may or may not move to the preceding line,
          Message 4 of 6 , Apr 2 8:21 AM
          View Source
          • 0 Attachment
            Thus saith HALIM,SALMAN:
            > perhaps i'm missing something, but why mess up the yank register by hitting
            > yiw? why not just use 'b'? (is it because the cursor might be at the first
            > character of the word?)

            That would be the major problem. Also, depending on options, a "b"
            taken with the cursor at the first column may or may not move to
            the preceding line, last word. One solution: use "lb" (move right
            one character, then back to beginning of word). This will fail if
            the word is a single character word on a line by itself. Seems
            the yiw trick works with all cases.

            Regards,
            Chip Campbell

            --
            Charles E Campbell, Jr, PhD _ __ __
            Goddard Space Flight Center / /_/\_\_/ /
            cec@... /_/ \/_//_/
            PGP public key: http://www.erols.com/astronaut/pgp.html
          • Thomas Köhler
            ... That s exactly why I use yiw :-) Of course, you can still use xyiw if you don t use the x register usually. That way, you don t kill a register you don t
            Message 5 of 6 , Apr 2 10:42 AM
            View Source
            • 0 Attachment
              Charles E. Campbell wrote [020402 20:36]:
              > Thus saith HALIM,SALMAN:
              > > perhaps i'm missing something, but why mess up the yank
              > > register by hitting yiw? why not just use 'b'? (is it
              > > because the cursor might be at the first character of the
              > > word?)
              >
              > That would be the major problem. Also, depending on options, a "b"
              > taken with the cursor at the first column may or may not move to
              > the preceding line, last word. One solution: use "lb" (move right
              > one character, then back to beginning of word). This will fail if
              > the word is a single character word on a line by itself. Seems
              > the yiw trick works with all cases.

              That's exactly why I use yiw :-)
              Of course, you can still use "xyiw if you don't use the x
              register usually. That way, you don't kill a register you don't
              want to...

              Ciao,
              Thomas

              --
              Thomas Köhler Email: jean-luc@... | LCARS - Linux
              <>< WWW: http://jeanluc-picard.de | for Computers
              IRC: jeanluc | on All Real
              PGP public key available from Homepage! | Starships
            • Kontra, Gergely
              ... A little off, but I hope it helps: Advertisement: Use mu-marks: http://vim.sourceforge.net/scripts/script.php?script_id=243 And type in your
              Message 6 of 6 , Apr 3 4:52 AM
              View Source
              • 0 Attachment
                >> How to replace a word under the cursor (say: junk) with another
                >> foojunkbar? when i am reading a paragraph, some of the word i
                >> want to change as \texttt{word}. i.e. the word under the
                >> cursor should come inside { }. how to do that in vim?

                A little off, but I hope it helps:
                Advertisement: Use mu-marks:
                http://vim.sourceforge.net/scripts/script.php?script_id=243

                And type in your ftplugin/tex.vim
                MarkMapB tt \texttt{Ťť}ŤĄť

                Then you can select the word visually, and press <C-Space>tt<CR>
                BTW: You can hack it, and use Ątt! in visual mode (if you want to bind
                to another keymap).
                You can use it in insertmode too.
                Type tt<C-Space>word<C-J>.

                Gergo

                +-[Kontra, Gergely @ Budapest University of Technology and Economics]-+
                | Email: kgergely@..., kgergely@... |
                | URL: turul.eet.bme.hu/~kgergely Mobile: (+36 20) 356 9656 |
                +-------"Olyan langesz vagyok, hogy poroltoval kellene jarnom!"-------+
                .
                Magyar php mirror es magyar php dokumentacio: http://hu.php.net
              Your message has been successfully submitted and would be delivered to recipients shortly.