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

simple question

Expand Messages
  • Jonah
    anyone know how to insert a blank line above or below the one you re on without entering insert mode? Basically an alternative to o and O . Thanks, Jonah
    Message 1 of 23 , Sep 5, 2001
    • 0 Attachment
      anyone know how to insert a blank line above or below
      the one you're on without entering insert mode? Basically
      an alternative to "o" and "O".

      Thanks,
      Jonah
    • Hans Fugal
      I d like to know too if there s an official way. But you could always map the key of your choice to do o or O then . Hans :) ... -- What an
      Message 2 of 23 , Sep 5, 2001
      • 0 Attachment
        I'd like to know too if there's an 'official' way. But you could always
        map the key of your choice to do 'o' or 'O' then <ESC>.

        Hans :)

        * Jonah (jgoldstein@...) thus spake:
        > anyone know how to insert a blank line above or below
        > the one you're on without entering insert mode? Basically
        > an alternative to "o" and "O".
        >
        > Thanks,
        > Jonah

        --
        What an incredible smell you've discovered!
      • Nagle, Adrian
        I do this: map ml o k Make a blank line below the current line map mL O j Make a blank line above the current line If there is a better way, I m
        Message 3 of 23 , Sep 5, 2001
        • 0 Attachment
          I do this:
          map ml o<ESC>k " Make a blank line below the current line
          map mL O<ESC>j " Make a blank line above the current line

          If there is a better way, I'm interested too.

          Adrian
          --
          Adrian Nagle anagle@...
          Thermal Engineer TEL: 303-939-6518
          Ball Aerospace & Technologies Corp. FAX: 303-939-5166
          Boulder, CO http://www.ballaerospace.com



          > -----Original Message-----
          > From: Jonah [SMTP:jgoldstein@...]
          > Sent: Wednesday, September 05, 2001 13:06
          > To: vim@...
          > Subject: simple question
          >
          > anyone know how to insert a blank line above or below
          > the one you're on without entering insert mode? Basically
          > an alternative to "o" and "O".
          >
          > Thanks,
          > Jonah
        • Benji Fisher
          ... If you want a single key that is defined to do this, I am pretty sure the answer is no. If you want to avoid Insert mode, there are a ... Go to an empty
          Message 4 of 23 , Sep 5, 2001
          • 0 Attachment
            Jonah wrote:
            >
            > anyone know how to insert a blank line above or below
            > the one you're on without entering insert mode? Basically
            > an alternative to "o" and "O".
            >
            > Thanks,
            > Jonah

            If you want a single key that is defined to do this, I am pretty
            sure the answer is no. If you want to avoid Insert mode, there are a
            few ways:

            :put='' " like o<Esc>
            :put!='' " like O<Esc>

            Go to an empty line, and yank it into your favorite register. ("qyy for
            example). Then

            "qp " like o<Esc>
            "qP " like O<Esc>

            The contents of the q register will be saved between sessions of Vim
            (assuming default options: something reasonable for 'viminfo').

            HTH --Benji Fisher
          • lwwickla@rockwellcollins.com
            Let me just add to that that I d like a method that, when editting in C++ and the cursor is on a line commented with a //, does not begin the next line with a
            Message 5 of 23 , Sep 5, 2001
            • 0 Attachment
              Let me just add to that that I'd like a method that, when editting in C++
              and the cursor is on a line commented with a //, does not begin the next
              line with a //.

              Thanks,

              Leif




              "Nagle, Adrian" <anagle@...> on 09/05/2001 02:12:58 PM

              To: vim@...
              cc: "'jgoldstein@...'" <jgoldstein@...>

              Subject: RE: simple question


              I do this:
              map ml o<ESC>k " Make a blank line below the current line
              map mL O<ESC>j " Make a blank line above the current line

              If there is a better way, I'm interested too.

              Adrian
              --
              Adrian Nagle anagle@...
              Thermal Engineer TEL: 303-939-6518
              Ball Aerospace & Technologies Corp. FAX: 303-939-5166
              Boulder, CO http://www.ballaerospace.com



              > -----Original Message-----
              > From: Jonah [SMTP:jgoldstein@...]
              > Sent: Wednesday, September 05, 2001 13:06
              > To: vim@...
              > Subject: simple question
              >
              > anyone know how to insert a blank line above or below
              > the one you're on without entering insert mode? Basically
              > an alternative to "o" and "O".
              >
              > Thanks,
              > Jonah
            • John Yochum
              ... look at ... I suspect that :set fo-=r should work for you. ... -- John Yochum Agilent Technologies john_yochum@agilent.com Imaging Electronics
              Message 6 of 23 , Sep 5, 2001
              • 0 Attachment
                * lwwickla@... <lwwickla@...> [010905 13:22]:
                >
                > Let me just add to that that I'd like a method that, when editting in C++
                > and the cursor is on a line commented with a //, does not begin the next
                > line with a //.
                >

                look at
                :help formatoptions
                :set fo
                I suspect that :set fo-=r should work for you.

                > "Nagle, Adrian" <anagle@...> on 09/05/2001 02:12:58 PM
                >
                > To: vim@...
                > cc: "'jgoldstein@...'" <jgoldstein@...>
                >
                > Subject: RE: simple question
                >
                >
                > I do this:
                > map ml o<ESC>k " Make a blank line below the current line
                > map mL O<ESC>j " Make a blank line above the current line
                >
                > If there is a better way, I'm interested too.
                >
                > Adrian
                > --
                > Adrian Nagle anagle@...
                > Thermal Engineer TEL: 303-939-6518
                > Ball Aerospace & Technologies Corp. FAX: 303-939-5166
                > Boulder, CO http://www.ballaerospace.com
                >
                >
                >
                > > -----Original Message-----
                > > From: Jonah [SMTP:jgoldstein@...]
                > > Sent: Wednesday, September 05, 2001 13:06
                > > To: vim@...
                > > Subject: simple question
                > >
                > > anyone know how to insert a blank line above or below
                > > the one you're on without entering insert mode? Basically
                > > an alternative to "o" and "O".
                > >
                > > Thanks,
                > > Jonah
                >
                >
                >
                >

                --
                John Yochum Agilent Technologies
                john_yochum@... Imaging Electronics Division
                (970) 288-0917 4380 Ziegler Road, MS 72
                (970) 288-6580 {fax} Fort Collins, CO 80525-9790
              • lwwickla@rockwellcollins.com
                Well, that would do what I want, but it would have the nasty side effect of no longer putting the leader in there when I hit Enter. The help on formatoptions
                Message 7 of 23 , Sep 5, 2001
                • 0 Attachment
                  Well, that would do what I want, but it would have the nasty side effect of
                  no longer putting the leader in there when I hit Enter.
                  The help on 'formatoptions' for "r" reads:
                  Automatically insert the current comment leader after hitting
                  <Enter> in Insert mode.

                  It would seem that the leader is being inserted more often than just when enter is hit.

                  In any event, I think the easiest solution to my problem would be something like

                  nmap <alt-o> O<esc>cc<esc>

                  Leif





                  John Yochum <loki@...> on 09/05/2001 02:28:59 PM

                  To: vim@...
                  cc:

                  Subject: Re: simple question


                  * lwwickla@... <lwwickla@...> [010905
                  13:22]:
                  >
                  > Let me just add to that that I'd like a method that, when editting in C++
                  > and the cursor is on a line commented with a //, does not begin the next
                  > line with a //.
                  >

                  look at
                  :help formatoptions
                  :set fo
                  I suspect that :set fo-=r should work for you.

                  > "Nagle, Adrian" <anagle@...> on 09/05/2001 02:12:58 PM
                  >
                  > To: vim@...
                  > cc: "'jgoldstein@...'" <jgoldstein@...>
                  >
                  > Subject: RE: simple question
                  >
                  >
                  > I do this:
                  > map ml o<ESC>k " Make a blank line below the current line
                  > map mL O<ESC>j " Make a blank line above the current line
                  >
                  > If there is a better way, I'm interested too.
                  >
                  > Adrian
                  > --
                  > Adrian Nagle anagle@...
                  > Thermal Engineer TEL: 303-939-6518
                  > Ball Aerospace & Technologies Corp. FAX: 303-939-5166
                  > Boulder, CO http://www.ballaerospace.com
                  >
                  >
                  >
                  > > -----Original Message-----
                  > > From: Jonah [SMTP:jgoldstein@...]
                  > > Sent: Wednesday, September 05, 2001 13:06
                  > > To: vim@...
                  > > Subject: simple question
                  > >
                  > > anyone know how to insert a blank line above or below
                  > > the one you're on without entering insert mode? Basically
                  > > an alternative to "o" and "O".
                  > >
                  > > Thanks,
                  > > Jonah
                  >
                  >
                  >
                  >

                  --
                  John Yochum Agilent Technologies
                  john_yochum@... Imaging Electronics Division
                  (970) 288-0917 4380 Ziegler Road, MS 72
                  (970) 288-6580 {fax} Fort Collins, CO 80525-9790
                • lwwickla@rockwellcollins.com
                  I d like to offer this suggestion to the original query: Add the following lines to your vimrc provide a way to insert a blank line above and below the
                  Message 8 of 23 , Sep 5, 2001
                  • 0 Attachment
                    I'd like to offer this suggestion to the original query:

                    Add the following lines to your vimrc
                    "provide a way to insert a blank line above and below the current one
                    nmap gO O<esc>cc<esc>j
                    nmap go o<esc>cc<esc>k

                    While this solution to this much answered query overwrites the default "go"
                    mapping, the same functionality is still available via the :go ex command.

                    HTH,

                    Leif




                    <lwwickla@...> on 09/05/2001 02:42:42 PM

                    To: loki@...
                    cc: vim@...

                    Subject: Re: simple question



                    Well, that would do what I want, but it would have the nasty side effect of
                    no longer putting the leader in there when I hit Enter.
                    The help on 'formatoptions' for "r" reads:
                    Automatically insert the current comment leader after hitting
                    <Enter> in Insert mode.

                    It would seem that the leader is being inserted more often than just when
                    enter is hit.

                    In any event, I think the easiest solution to my problem would be something
                    like

                    nmap <alt-o> O<esc>cc<esc>

                    Leif





                    John Yochum <loki@...> on 09/05/2001 02:28:59 PM

                    To: vim@...
                    cc:

                    Subject: Re: simple question


                    * lwwickla@... <lwwickla@...> [010905
                    13:22]:
                    >
                    > Let me just add to that that I'd like a method that, when editting in C++
                    > and the cursor is on a line commented with a //, does not begin the next
                    > line with a //.
                    >

                    look at
                    :help formatoptions
                    :set fo
                    I suspect that :set fo-=r should work for you.

                    > "Nagle, Adrian" <anagle@...> on 09/05/2001 02:12:58 PM
                    >
                    > To: vim@...
                    > cc: "'jgoldstein@...'" <jgoldstein@...>
                    >
                    > Subject: RE: simple question
                    >
                    >
                    > I do this:
                    > map ml o<ESC>k " Make a blank line below the current line
                    > map mL O<ESC>j " Make a blank line above the current line
                    >
                    > If there is a better way, I'm interested too.
                    >
                    > Adrian
                    > --
                    > Adrian Nagle anagle@...
                    > Thermal Engineer TEL: 303-939-6518
                    > Ball Aerospace & Technologies Corp. FAX: 303-939-5166
                    > Boulder, CO http://www.ballaerospace.com
                    >
                    >
                    >
                    > > -----Original Message-----
                    > > From: Jonah [SMTP:jgoldstein@...]
                    > > Sent: Wednesday, September 05, 2001 13:06
                    > > To: vim@...
                    > > Subject: simple question
                    > >
                    > > anyone know how to insert a blank line above or below
                    > > the one you're on without entering insert mode? Basically
                    > > an alternative to "o" and "O".
                    > >
                    > > Thanks,
                    > > Jonah
                    >
                    >
                    >
                    >

                    --
                    John Yochum Agilent Technologies
                    john_yochum@... Imaging Electronics Division
                    (970) 288-0917 4380 Ziegler Road, MS 72
                    (970) 288-6580 {fax} Fort Collins, CO 80525-9790
                  • Benji Fisher
                    ... A slightly simpler version is ... You might want to add ... Or you could just type the yourself. More key strokes, but easier to remember. HTH
                    Message 9 of 23 , Sep 5, 2001
                    • 0 Attachment
                      lwwickla@... wrote:
                      >
                      > Well, that would do what I want, but it would have the nasty side effect of
                      > no longer putting the leader in there when I hit Enter.
                      > The help on 'formatoptions' for "r" reads:
                      > Automatically insert the current comment leader after hitting
                      > <Enter> in Insert mode.
                      >
                      > It would seem that the leader is being inserted more often than just when enter is hit.
                      >
                      > In any event, I think the easiest solution to my problem would be something like
                      >
                      > nmap <alt-o> O<esc>cc<esc>
                      >
                      > Leif

                      A slightly simpler version is

                      :nmap <m-o> O<C-U>

                      You might want to add

                      :imap <m-o> <CR><C-U>

                      Or you could just type the <C-U> yourself. More key strokes, but easier
                      to remember.

                      HTH --Benji Fisher
                    • John Yochum
                      ... I guess I don t know when you do want the comment leader in and when you don t? Could you be more explicit? ... leader operation, not to mention just
                      Message 10 of 23 , Sep 5, 2001
                      • 0 Attachment
                        * lwwickla@... <lwwickla@...> [010905 13:43]:
                        >
                        > Well, that would do what I want, but it would have the nasty side effect of
                        > no longer putting the leader in there when I hit Enter.
                        > The help on 'formatoptions' for "r" reads:
                        > Automatically insert the current comment leader after hitting
                        > <Enter> in Insert mode.

                        I guess I don't know when you do want the comment leader in and when you
                        don't? Could you be more explicit?

                        >
                        > It would seem that the leader is being inserted more often than just when enter is hit.
                        :help fo-table shows that tho o option also affects the comment
                        leader operation, not to mention just below the table it says that C
                        code comments are treated smartly if \* starts a line it reacts
                        differently...There might be a way to add that functionality for C++,
                        though you might have to code it in yourself....:-)

                        <original problem snipped>
                        >
                        >
                        > John Yochum <loki@...> on 09/05/2001 02:28:59 PM
                        >
                        > To: vim@...
                        > cc:
                        >
                        > Subject: Re: simple question
                        >
                        >
                        > * lwwickla@... <lwwickla@...> [010905
                        > 13:22]:
                        > >
                        > > Let me just add to that that I'd like a method that, when editting in C++
                        > > and the cursor is on a line commented with a //, does not begin the next
                        > > line with a //.
                        > >
                        >
                        > look at
                        > :help formatoptions
                        > :set fo
                        > I suspect that :set fo-=r should work for you.
                        >
                        --
                        John Yochum Agilent Technologies
                        john_yochum@... Imaging Electronics Division
                        (970) 288-0917 4380 Ziegler Road, MS 72
                        (970) 288-6580 {fax} Fort Collins, CO 80525-9790
                      • Dan Sharp
                        ... Go down one more line and look at the o format option. o Automatically insert the current comment leader after hitting o or O in Normal mode.
                        Message 11 of 23 , Sep 5, 2001
                        • 0 Attachment
                          At 02:42 PM 9/5/2001 -0500, lwwickla@... wrote:

                          >Well, that would do what I want, but it would have the nasty side effect of
                          >no longer putting the leader in there when I hit Enter.
                          >The help on 'formatoptions' for "r" reads:
                          > Automatically insert the current comment leader after hitting
                          > <Enter> in Insert mode.
                          >
                          >It would seem that the leader is being inserted more often than just when
                          >enter is hit.
                          >
                          >In any event, I think the easiest solution to my problem would be
                          >something like
                          >
                          >nmap <alt-o> O<esc>cc<esc>

                          Go down one more line and look at the "o" format option.

                          o Automatically insert the current comment leader after hitting 'o' or
                          'O' in Normal mode.

                          Remove "o" from formatoptions to get the effect you want.

                          Dan Sharp
                        • Ed Grimm
                          Use the editor, Luke! map ml :a.k map mL k:a.j Ed
                          Message 12 of 23 , Sep 5, 2001
                          • 0 Attachment
                            Use the editor, Luke!

                            map ml :a.k
                            map mL k:a.j

                            Ed

                            On Wed, 5 Sep 2001, Jonah wrote:

                            > anyone know how to insert a blank line above or below
                            > the one you're on without entering insert mode? Basically
                            > an alternative to "o" and "O".
                            >
                            > Thanks,
                            > Jonah
                            >
                          • Preben Guldberg
                            ... Don t you need some s in there? (and, btw, for mL there is :i as well) Peppe [Seen too much vi lately, so was thinking :t-|s/.*// for ex :-)] --
                            Message 13 of 23 , Sep 6, 2001
                            • 0 Attachment
                              Thus wrote Ed Grimm (edgrimm@...) on [010905]:
                              > Use the editor, Luke!

                              > map ml :a.k
                              > map mL k:a.j

                              Don't you need some <CR>s in there? (and, btw, for mL there is ":i" as
                              well)

                              Peppe [Seen too much vi lately, so was thinking ":t-|s/.*//" for ex :-)]
                              --
                              "Before you criticize someone, walk
                              Preben "Peppe" Guldberg __/-\__ a mile in his shoes. That way, if
                              c928400@... (o o) he gets angry, he'll be a mile away
                              ----------------------oOOo (_) oOOo-- - and barefoot." --Sarah Jackson
                            • Ed Grimm
                              ... There were. Unfortunately, I foolishly put them in litterally, and my MTA deleted them as possibly dangerous non-printable characters I know about :i,
                              Message 14 of 23 , Sep 6, 2001
                              • 0 Attachment
                                On Thu, 6 Sep 2001, Preben Guldberg wrote:
                                > Thus wrote Ed Grimm (edgrimm@...) on [010905]:
                                >> Use the editor, Luke!
                                >
                                >> map ml :a.k
                                >> map mL k:a.j
                                >
                                > Don't you need some <CR>s in there? (and, btw, for mL there is ":i" as
                                > well)

                                There were. Unfortunately, I foolishly put them in litterally, and my
                                MTA deleted them as 'possibly dangerous non-printable characters'


                                I know about :i, but I was just knocking that off quickly without
                                thinking to show that it could be done quickly and without thinking if
                                you only remember your full toolset available.

                                Ed
                              • Jonah
                                i would like to know how to make lines wrap in vim. it know it should be some simple combination of textwidth,wrapmargin, and formatoptions, but just can t get
                                Message 15 of 23 , Jan 21, 2002
                                • 0 Attachment
                                  i would like to know how to make lines wrap in vim.
                                  it know it should be some simple combination of
                                  textwidth,wrapmargin, and formatoptions, but just
                                  can't get it to work. When I type, I would like
                                  the line to automatically break at 80 characters,
                                  bringing the current word down to the next line, in
                                  the same way that a word processing program does.

                                  also, i would like to be able to turn this behaviour
                                  on an off, so that i can use it for normal writing
                                  and avoid it when writing code.

                                  any help will be much appreciated.

                                  thanks,
                                  jonah
                                • Andrew Stryker
                                  ... Make sure formatoptions includes t and that textwidth is greater than 0. So ... should meet your request. ... Setting textwidth to 0 turns the wrapping
                                  Message 16 of 23 , Jan 21, 2002
                                  • 0 Attachment
                                    Jonah <jgoldstein@...> wrote on 2002-Jan-21:
                                    > i would like to know how to make lines wrap in vim.
                                    > it know it should be some simple combination of
                                    > textwidth,wrapmargin, and formatoptions, but just
                                    > can't get it to work. When I type, I would like
                                    > the line to automatically break at 80 characters,
                                    > bringing the current word down to the next line, in
                                    > the same way that a word processing program does.

                                    Make sure formatoptions includes "t" and that textwidth is greater
                                    than 0. So

                                    :set formatoptions+=t
                                    :set textwidth=80

                                    should meet your request.

                                    > also, i would like to be able to turn this behaviour
                                    > on an off, so that i can use it for normal writing
                                    > and avoid it when writing code.

                                    Setting textwidth to 0 turns the wrapping off.

                                    HTH,

                                    Andrew
                                  • Jonah
                                    andrew, thanks. do you know if, in addition, you can make words automatically jump up from the line below when you delete words from the current line. again,
                                    Message 17 of 23 , Jan 21, 2002
                                    • 0 Attachment
                                      andrew, thanks.

                                      do you know if, in addition, you can make words automatically
                                      jump up from the line below when you delete words from the
                                      current line. again, the same way a typical word processor
                                      works.

                                      i know you could highlight the lines in question and hit 'gq',
                                      but i wonder if there is some way to automate this.

                                      thanks again,
                                      jonah

                                      -----Original Message-----
                                      From: Andrew Stryker [mailto:astryk1@...]
                                      Sent: Monday, January 21, 2002 9:08 AM
                                      To: Jonah
                                      Cc: vim@...
                                      Subject: Re: simple question


                                      Jonah <jgoldstein@...> wrote on 2002-Jan-21:
                                      > i would like to know how to make lines wrap in vim.
                                      > it know it should be some simple combination of
                                      > textwidth,wrapmargin, and formatoptions, but just
                                      > can't get it to work. When I type, I would like
                                      > the line to automatically break at 80 characters,
                                      > bringing the current word down to the next line, in
                                      > the same way that a word processing program does.

                                      Make sure formatoptions includes "t" and that textwidth is greater
                                      than 0. So

                                      :set formatoptions+=t
                                      :set textwidth=80

                                      should meet your request.

                                      > also, i would like to be able to turn this behaviour
                                      > on an off, so that i can use it for normal writing
                                      > and avoid it when writing code.

                                      Setting textwidth to 0 turns the wrapping off.

                                      HTH,

                                      Andrew
                                    • Jack Troughton
                                      I find «:set wrap» and «:set nowrap» to be very effective.
                                      Message 18 of 23 , Jan 21, 2002
                                      • 0 Attachment
                                        I find «:set wrap» and «:set nowrap» to be very effective.

                                        Andrew Stryker wrote:
                                        >
                                        > Jonah <jgoldstein@...> wrote on 2002-Jan-21:
                                        > > i would like to know how to make lines wrap in vim.
                                        > > it know it should be some simple combination of
                                        > > textwidth,wrapmargin, and formatoptions, but just
                                        > > can't get it to work. When I type, I would like
                                        > > the line to automatically break at 80 characters,
                                        > > bringing the current word down to the next line, in
                                        > > the same way that a word processing program does.
                                        >
                                        > Make sure formatoptions includes "t" and that textwidth is greater
                                        > than 0. So
                                        >
                                        > :set formatoptions+=t
                                        > :set textwidth=80
                                        >
                                        > should meet your request.
                                        >
                                        > > also, i would like to be able to turn this behaviour
                                        > > on an off, so that i can use it for normal writing
                                        > > and avoid it when writing code.
                                        >
                                        > Setting textwidth to 0 turns the wrapping off.
                                        >
                                        > HTH,
                                        >
                                        > Andrew
                                      • Jack Troughton
                                        «dd» Deletes the line. If you re asking about deleting part of the line and having the wrap go automatically, I don t know... I just wait until I m done the
                                        Message 19 of 23 , Jan 21, 2002
                                        • 0 Attachment
                                          «dd»

                                          Deletes the line. If you're asking about deleting part of the line and
                                          having the wrap go automatically, I don't know... I just wait until I'm
                                          done the paragraph and do a

                                          gqip

                                          to reformat the paragraph.

                                          Jonah wrote:
                                          >
                                          > andrew, thanks.
                                          >
                                          > do you know if, in addition, you can make words automatically
                                          > jump up from the line below when you delete words from the
                                          > current line. again, the same way a typical word processor
                                          > works.
                                          >
                                          > i know you could highlight the lines in question and hit 'gq',
                                          > but i wonder if there is some way to automate this.
                                          >
                                          > thanks again,
                                          > jonah
                                          >
                                          > -----Original Message-----
                                          > From: Andrew Stryker [mailto:astryk1@...]
                                          > Sent: Monday, January 21, 2002 9:08 AM
                                          > To: Jonah
                                          > Cc: vim@...
                                          > Subject: Re: simple question
                                          >
                                          > Jonah <jgoldstein@...> wrote on 2002-Jan-21:
                                          > > i would like to know how to make lines wrap in vim.
                                          > > it know it should be some simple combination of
                                          > > textwidth,wrapmargin, and formatoptions, but just
                                          > > can't get it to work. When I type, I would like
                                          > > the line to automatically break at 80 characters,
                                          > > bringing the current word down to the next line, in
                                          > > the same way that a word processing program does.
                                          >
                                          > Make sure formatoptions includes "t" and that textwidth is greater
                                          > than 0. So
                                          >
                                          > :set formatoptions+=t
                                          > :set textwidth=80
                                          >
                                          > should meet your request.
                                          >
                                          > > also, i would like to be able to turn this behaviour
                                          > > on an off, so that i can use it for normal writing
                                          > > and avoid it when writing code.
                                          >
                                          > Setting textwidth to 0 turns the wrapping off.
                                          >
                                          > HTH,
                                          >
                                          > Andrew
                                        • Andrew Stryker
                                          ... You re welcome. ... Not so simple. You would have to tell Vim to reformat every paragraph each time a key is pressed. If there was a KeyPress autocmd
                                          Message 20 of 23 , Jan 21, 2002
                                          • 0 Attachment
                                            Jonah <jgoldstein@...> wrote on 2002-Jan-21:
                                            > andrew, thanks.

                                            You're welcome.

                                            > do you know if, in addition, you can make words automatically
                                            > jump up from the line below when you delete words from the
                                            > current line. again, the same way a typical word processor
                                            > works.
                                            >
                                            > i know you could highlight the lines in question and hit 'gq',
                                            > but i wonder if there is some way to automate this.

                                            Not so simple. You would have to tell Vim to reformat every
                                            paragraph each time a key is pressed. If there was a "KeyPress"
                                            autocmd event, I suppose you could trigger such a function. But
                                            there isn't.

                                            You may wish to explore mapping functions to the return key, <CR>,
                                            and escape, <ESC>, while in insert mode. (Use imap.) Vim could
                                            call a function that reformats the current paragraph. Probably
                                            using "gqip". However, I am not an expert function writer.
                                            Perhaps others will have more to say.

                                            Andrew
                                          • Artem B. Bityuckiy
                                            Hello guys. I can t perform the following task with vim: I have a number of files with BSD-license header: /*- * Copyright (c) 2000 * Konstantin Chuguev.
                                            Message 21 of 23 , Dec 3, 2003
                                            • 0 Attachment
                                              Hello guys. I can't perform the following task with vim:

                                              I have a number of files with BSD-license header:

                                              /*-
                                              * Copyright (c) 2000
                                              * Konstantin Chuguev. All rights reserved.
                                              *
                                              * Redistribution and use in source and binary forms, with or without
                                              * modification, are permitted provided that the following conditions
                                              * are met:
                                              * 1. Redistributions of source code must retain the above copyright
                                              * notice, this list of conditions and the following disclaimer.
                                              * 2. Redistributions in binary form must reproduce the above copyright
                                              * notice, this list of conditions and the following disclaimer in the
                                              * documentation and/or other materials provided with the distribution.
                                              *
                                              * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
                                              * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                                              * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                                              PURPOSE
                                              * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
                                              * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                                              CONSEQUENTIAL
                                              * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                                              * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                                              * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
                                              STRICT
                                              * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
                                              ANY WAY
                                              * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                                              * SUCH DAMAGE.
                                              *
                                              * iconv (Charset Conversion Library) v2.0
                                              */

                                              I want to remove the 3 advertising clause (with permission of authors)
                                              from it, i.e the following lines:

                                              * 3. All advertising materials mentioning features or use of this software
                                              * must display the following acknowledgement:
                                              * This product includes software developed by Konstantin Chuguev
                                              * and its contributors.

                                              How to do so?

                                              Note, that some files are perl files and their comment is beginning with
                                              '#' symbol.

                                              I've tried to do the following:
                                              / \* 3. All advertising materials mentioning features or use of this
                                              software\
                                              n \* must display the following acknowledgement:\n \*\tThis product
                                              includes
                                              software developed by Konstantin Chuguev\n \*\tand its contributors.\n/d

                                              but only two first lines are deleted. Also, in some files '\t'
                                              characters are substituted by whitespaces and search don't match.

                                              The right way is to do the following:
                                              1. find "All advertising materials mentioning" pattern
                                              2. delete this line and 3 lines above.

                                              But how to do this?

                                              I've opened all such files by

                                              > vim `grep -l -r "Redistribution and use in source and binary forms" *`
                                              command.

                                              What's next?

                                              Thanks.





                                              --
                                              Best Regards,
                                              Artem B. Bityuckiy,
                                              St.-Petersburg, Russia.
                                            • Jürgen Krämer
                                              Hi, ... if there are always 4 lines, you can do ... Regards, Jürgen -- Jürgen Krämer Softwareentwicklung Habel GmbH
                                              Message 22 of 23 , Dec 3, 2003
                                              • 0 Attachment
                                                Hi,

                                                Artem B. Bityuckiy wrote:
                                                >
                                                > I have a number of files with BSD-license header:
                                                >
                                                > /*-
                                                > * Copyright (c) 2000
                                                > * Konstantin Chuguev. All rights reserved.
                                                > *
                                                > * Redistribution and use in source and binary forms, with or without
                                                > * modification, are permitted provided that the following conditions
                                                > * are met:
                                                > * 1. Redistributions of source code must retain the above copyright
                                                > * notice, this list of conditions and the following disclaimer.
                                                > * 2. Redistributions in binary form must reproduce the above copyright
                                                > * notice, this list of conditions and the following disclaimer in the
                                                > * documentation and/or other materials provided with the distribution.
                                                > *
                                                > * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
                                                > * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                                                > * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
                                                > PURPOSE
                                                > * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
                                                > * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
                                                > CONSEQUENTIAL
                                                > * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                                                > * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                                                > * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
                                                > STRICT
                                                > * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
                                                > ANY WAY
                                                > * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                                                > * SUCH DAMAGE.
                                                > *
                                                > * iconv (Charset Conversion Library) v2.0
                                                > */
                                                >
                                                > I want to remove the 3 advertising clause (with permission of authors)
                                                > from it, i.e the following lines:
                                                >
                                                > * 3. All advertising materials mentioning features or use of this software
                                                > * must display the following acknowledgement:
                                                > * This product includes software developed by Konstantin Chuguev
                                                > * and its contributors.

                                                if there are always 4 lines, you can do

                                                :g/3\. All advertising materials/,+3d

                                                Regards,
                                                Jürgen

                                                --
                                                Jürgen Krämer Softwareentwicklung
                                                Habel GmbH mailto:jkr@...
                                                Hinteres Öschle 2 Tel: (0 74 61) 93 53 15
                                                78604 Rietheim-Weilheim Fax: (0 74 61) 93 53 99
                                              • Tim Chase
                                                ... *` ... Looks like a job for argdo and an ex command. Something like this one-liner (if OE breaks the line, just make sure it s keyed in as one line) ...
                                                Message 23 of 23 , Dec 3, 2003
                                                • 0 Attachment
                                                  > The right way is to do the following:
                                                  > 1. find "All advertising materials mentioning" pattern
                                                  > 2. delete this line and 3 lines above.
                                                  >
                                                  > But how to do this?
                                                  >
                                                  > I've opened all such files by
                                                  >
                                                  > > vim `grep -l -r "Redistribution and use in source and binary forms"
                                                  *`
                                                  > command.
                                                  >
                                                  > What's next?

                                                  Looks like a job for argdo and an ex command. Something like this
                                                  one-liner (if OE breaks the line, just make sure it's keyed in as one
                                                  line)

                                                  :argdo 1/All advertising materials mentioning/-3,/All advertising
                                                  materials mentioning/-1d

                                                  should do the trick if it's truely the three lines *above* that you want
                                                  to delete.

                                                  Jurgen's answer was close, however, if you have any *other* lines
                                                  (improbable as it may be) that match that regex, it will hose them too.
                                                  It also deletes the three lines *following* the "All advertising..." line.
                                                  If it's the three lines *after* that you want, but you only want to do it
                                                  for the first instance, this will pull it off:

                                                  :argdo 1/All advertising materials/+1,+2d

                                                  The first one breaks down as

                                                  :argdo for each file in the argument list
                                                  1 go to the first line
                                                  /All ..ning/ search for the text
                                                  -3 beginning three lines before it
                                                  , and ending at
                                                  /All ..ning/ where you find the next bit of text from that starting point
                                                  -1 the line before the one you just found
                                                  d delete 'em

                                                  The second one breaks down a little more cleanly, the same as the above
                                                  only
                                                  +1 the line after the search result
                                                  , through
                                                  +2 two lines after the line we just found
                                                  d delete it

                                                  You'll want to make sure you have 'hidden' set so you can approve all the
                                                  changes, and then you can either :w them each as you confirm the
                                                  correctness, or just :wall them to write them all.

                                                  If you have faith, you can skip having 'hidden' set, and just append a
                                                  pipe followed by a "w" to write each file after the changes have been made

                                                  :argdo 1/All advertising materials/+1,+2d|w

                                                  HTH,

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