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

quick way of commenting?

Expand Messages
  • Geoff Ludwiczak
    Hi, Does anyone know of a quick way of commenting out several lines after selecting them with the visual mode using V . Thanks!
    Message 1 of 10 , Aug 12, 2001
    • 0 Attachment
      Hi,

      Does anyone know of a quick way of commenting out several lines after
      selecting them with the visual mode using 'V'.

      Thanks!
    • Thomas Köhler
      On Sun, Aug 12, 2001 at 02:55:27PM -0700, ... I use this: commenting in and out C code nmap ,q :.!boxes -d c-cmt nmap ,Q :.!boxes -d c-cmt -r vmap ,q
      Message 2 of 10 , Aug 12, 2001
      • 0 Attachment
        On Sun, Aug 12, 2001 at 02:55:27PM -0700,
        Geoff Ludwiczak <ludwicza@...> wrote:
        > Hi,
        >
        > Does anyone know of a quick way of commenting out several lines after
        > selecting them with the visual mode using 'V'.
        >
        > Thanks!

        I use this:

        " commenting in and out C code
        nmap ,q :.!boxes -d c-cmt<CR>
        nmap ,Q :.!boxes -d c-cmt -r<CR>
        vmap ,q :!boxes -d c-cmt<CR>
        vmap ,Q :!boxes -d c-cmt -r<CR>

        The boxes program is available from
        http://home.pages.de/~jensen/boxes/

        HTH,
        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
      • Adam 'Vonlia' Seyfarth
        ... ... you don t _really_ need the : there, ! in insert-mode will expand to :` ! , which will work on the whole selection. PS: I use the , command a
        Message 3 of 10 , Aug 12, 2001
        • 0 Attachment
          On Mon, 13 Aug 2001, Thomas Köhler wrote:

          > On Sun, Aug 12, 2001 at 02:55:27PM -0700,
          > Geoff Ludwiczak <ludwicza@...> wrote:
          ...
          > vmap ,q :!boxes -d c-cmt<CR>
          > vmap ,Q :!boxes -d c-cmt -r<CR>
          ...
          you don't _really_ need the ':' there, '!' in insert-mode will expand to
          ':`<,`>!', which will work on the whole selection.

          PS: I use the ',' command a reasonably good bit, I recommend using
          '<Leader>' so it is customizable...


          --
          I always wondered about the meaning of life. so I looked it up in
          the dictionary under "L" and there is was - the meaning of life.
          It was not what I had expected.
          -- Dogbert

          /|| Adam Seyfarth <http://members.home.net/adam.seyfarth/> ||\
          /«|| <mailto:cloud@...> <http://www.majik3d.org> ||»\
          \«|| <http://tuxaqfh.sf.net> <http://tuxkart.sf.net> ||»/
          \|| <http://vim.sf.net> <http://www.majik3d.org> ||/
        • Jonathan Gardner
          ... try ... It s a simple way, really... Jonathan
          Message 4 of 10 , Aug 12, 2001
          • 0 Attachment
            On Sunday 12 August 2001 03:22 pm, you wrote:
            > On Mon, 13 Aug 2001, Thomas Köhler wrote:
            > > On Sun, Aug 12, 2001 at 02:55:27PM -0700,
            > > Geoff Ludwiczak <ludwicza@...> wrote:
            >
            > ...
            >
            > > vmap ,q :!boxes -d c-cmt<CR>
            > > vmap ,Q :!boxes -d c-cmt -r<CR>
            >
            > ...
            > you don't _really_ need the ':' there, '!' in insert-mode will expand to
            > ':`<,`>!', which will work on the whole selection.
            >
            > PS: I use the ',' command a reasonably good bit, I recommend using
            > '<Leader>' so it is customizable...

            try

            :s/^/#/

            To uncomment, select the block then:

            :s/#//

            It's a simple way, really...

            Jonathan
          • Thomas Köhler
            On Sun, Aug 12, 2001 at 05:22:19PM -0500, ... Of course, you re right here. :-) ... Those mappings were in my .vimrc before anyone even thought of
            Message 5 of 10 , Aug 13, 2001
            • 0 Attachment
              On Sun, Aug 12, 2001 at 05:22:19PM -0500,
              Adam 'Vonlia' Seyfarth <adam.seyfarth@...> wrote:
              > On Mon, 13 Aug 2001, Thomas Köhler wrote:
              >
              > > On Sun, Aug 12, 2001 at 02:55:27PM -0700,
              > > Geoff Ludwiczak <ludwicza@...> wrote:
              > ...
              > > vmap ,q :!boxes -d c-cmt<CR>
              > > vmap ,Q :!boxes -d c-cmt -r<CR>
              > ...
              > you don't _really_ need the ':' there, '!' in insert-mode will expand to
              > ':`<,`>!', which will work on the whole selection.

              Of course, you're right here. :-)

              > PS: I use the ',' command a reasonably good bit, I recommend using
              > '<Leader>' so it is customizable...

              Those mappings were in my .vimrc before anyone even thought of
              "<Leader>" ;-)

              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
            • Pavel Tavoda
              Good hint, but how you deal with characters. My are always converted to spaces. Pavel
              Message 6 of 10 , Aug 13, 2001
              • 0 Attachment
                Good hint, but how you deal with <tab> characters. My are always
                converted to spaces.

                Pavel

                Thomas Köhler wrote:

                >On Sun, Aug 12, 2001 at 02:55:27PM -0700,
                >Geoff Ludwiczak <ludwicza@...> wrote:
                >
                >>Hi,
                >>
                >>Does anyone know of a quick way of commenting out several lines after
                >>selecting them with the visual mode using 'V'.
                >>
                >>Thanks!
                >>
                >
                >I use this:
                >
                >" commenting in and out C code
                >nmap ,q :.!boxes -d c-cmt<CR>
                >nmap ,Q :.!boxes -d c-cmt -r<CR>
                >vmap ,q :!boxes -d c-cmt<CR>
                >vmap ,Q :!boxes -d c-cmt -r<CR>
                >
                >The boxes program is available from
                >http://home.pages.de/~jensen/boxes/
                >
                >HTH,
                >Thomas
                >
              • Pavel Tavoda
                I m working in Java. For writing real (javadoc) comments I m using prepared templates like ... And uncomenting ... or make a maping ;-) Pavel
                Message 7 of 10 , Aug 13, 2001
                • 0 Attachment
                  I'm working in Java.
                  For writing real (javadoc) comments I'm using prepared templates like
                  :read ~/bin/myClassDocTemplate.txt

                  For commenting out some piece of of code in visual mode type:
                  :s#^#// #
                  And uncomenting
                  :s#^// ##

                  or make a maping ;-)

                  Pavel

                  Geoff Ludwiczak wrote:

                  >Hi,
                  >
                  >Does anyone know of a quick way of commenting out several lines after
                  >selecting them with the visual mode using 'V'.
                  >
                  >Thanks!
                  >
                • Thomas Köhler
                  On Mon, Aug 13, 2001 at 12:40:19PM +0200, ... I personally don t use any tabs, and use the expandtab option. ... Ciao, Thomas -- Thomas Köhler Email:
                  Message 8 of 10 , Aug 13, 2001
                  • 0 Attachment
                    On Mon, Aug 13, 2001 at 12:40:19PM +0200,
                    Pavel Tavoda <tavoda@...> wrote:
                    >
                    > Good hint, but how you deal with <tab> characters. My are always
                    > converted to spaces.

                    :help retab

                    I personally don't use any tabs, and use the 'expandtab' option.

                    > Pavel
                    >
                    > Thomas Köhler wrote:
                    >
                    > >On Sun, Aug 12, 2001 at 02:55:27PM -0700,
                    > >Geoff Ludwiczak <ludwicza@...> wrote:
                    > >
                    > >>Hi,
                    > >>
                    > >>Does anyone know of a quick way of commenting out several lines after
                    > >>selecting them with the visual mode using 'V'.
                    > >>
                    > >>Thanks!
                    > >>
                    > >
                    > >I use this:
                    > >
                    > >" commenting in and out C code
                    > >nmap ,q :.!boxes -d c-cmt<CR>
                    > >nmap ,Q :.!boxes -d c-cmt -r<CR>
                    > >vmap ,q :!boxes -d c-cmt<CR>
                    > >vmap ,Q :!boxes -d c-cmt -r<CR>
                    > >
                    > >The boxes program is available from
                    > >http://home.pages.de/~jensen/boxes/

                    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
                  • Jeff Walker
                    Since I am a c & c++ programmer, do this. vmap ^[
                    Message 9 of 10 , Aug 13, 2001
                    • 0 Attachment
                      Since I am a c & c++ programmer, do this.

                      vmap <m-i> ^['<O#if 0^['>o#endif^[

                      This puts "#if 0" and "#endif" around a visually selected block.

                      I like this better for multiline actions because you can nest these with
                      anything (used to do "/*" & "*/", but then it messed up the comments
                      inside). Also, you can easily change the 0 to 1 if you want to experiment,
                      or use an "#else" block to put in some code to use instead, and easily
                      toggle between them (using 0 or 1 in the "#if" part).

                      One thing, though, some compilers (maybe not many anymore) might complain if
                      the code in between is not compliable. According to the standard, it still
                      has to be valid c code, but I haven't seen a compiler that enforced this
                      since the early 90's, but YMMV.

                      HTH

                      --
                      Jeff Walker MatchLogic, Inc.
                      jwalker@... 7233 Church Ranch Blvd.
                      Voice 1 (303) 222-2105 Westminster, CO 80021
                      Fax 1 (303) 222-2001 www.matchlogic.com


                      -----Original Message-----
                      From: Geoff Ludwiczak [mailto:ludwicza@...]
                      Sent: Sunday, August 12, 2001 3:55 PM
                      To: vim@...
                      Subject: quick way of commenting?


                      Hi,

                      Does anyone know of a quick way of commenting out several lines after
                      selecting them with the visual mode using 'V'.

                      Thanks!
                    • Thomas Köhler
                      On Mon, Aug 13, 2001 at 10:01:42AM -0600, ... boxes takes care of that. See this example: foo(); ... v /* foo(); */ ... v /* /* foo(); * / */ ... v /* /* /*
                      Message 10 of 10 , Aug 13, 2001
                      • 0 Attachment
                        On Mon, Aug 13, 2001 at 10:01:42AM -0600,
                        Jeff Walker <jwalker@...> wrote:
                        > Since I am a c & c++ programmer, do this.
                        >
                        > vmap <m-i> ^['<O#if 0^['>o#endif^[
                        >
                        > This puts "#if 0" and "#endif" around a visually selected block.
                        >
                        > I like this better for multiline actions because you can nest these with
                        > anything (used to do "/*" & "*/", but then it messed up the comments
                        > inside).

                        "boxes" takes care of that.

                        See this example:

                        foo();
                        |
                        | :.!boxes -d c-cmt
                        v
                        /* foo(); */
                        |
                        | :.!boxes -d c-cmt
                        v
                        /* /* foo(); *\/ */
                        | ^------ note this
                        | :.!boxes -d c-cmt
                        v
                        /* /* /* foo(); *\/ *\/ */
                        | ^---^---- note these
                        | :.!boxes -d c-cmt -r
                        v
                        /* /* foo(); *\/ */
                        | ^--- "\" gone again
                        | :.!boxes -d c-cmt -r
                        v
                        /* foo(); */
                        |
                        | :.!boxes -d c-cmt -r
                        v
                        foo();

                        nmap ,q :.!boxes -d c-cmt<CR>
                        nmap ,Q :.!boxes -d c-cmt -r<CR>
                        vmap ,q :!boxes -d c-cmt<CR>
                        vmap ,Q :!boxes -d c-cmt -r<CR>

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