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

textwidth

Expand Messages
  • A. S. Budden
    Hi there, Is there anyway to take a file that has each paragraph on one line, and auto wrap it as if it had been typed with textwidth=72 on (observing word
    Message 1 of 15 , Feb 26, 2003
    • 0 Attachment
      Hi there,

      Is there anyway to take a file that has each paragraph on one line, and
      auto wrap it as if it had been typed with textwidth=72 on (observing
      word breaks etc).

      Cheers in advance,

      Al
    • Jürgen Krämer
      Hi, ... Regards, Jürgen -- Jürgen Krämer Softwareentwicklung Habel GmbH
      Message 2 of 15 , Feb 26, 2003
      • 0 Attachment
        Hi,

        A. S. Budden wrote:
        >
        > Is there anyway to take a file that has each paragraph on one line, and
        > auto wrap it as if it had been typed with textwidth=72 on (observing
        > word breaks etc).

        :set tw=72 | g/./normal gqq

        Regards,
        Jürgen

        --
        Jürgen Krämer Softwareentwicklung
        Habel GmbH mailto:jkraemer@...
        Hinteres Öschle 2 Tel: (0 74 61) 93 53 15
        78604 Rietheim-Weilheim Fax: (0 74 61) 93 53 99
      • Bowie Bailey
        ... gggqG gg - move to the top gqG - wrap paragraphs from here to the end of the buffer Bowie
        Message 3 of 15 , Feb 26, 2003
        • 0 Attachment
          > From: A. S. Budden [mailto:vim.mail@...]
          >
          > Hi there,
          >
          > Is there anyway to take a file that has each paragraph on one
          > line, and
          > auto wrap it as if it had been typed with textwidth=72 on (observing
          > word breaks etc).

          :set tw=72
          gggqG

          gg - move to the top
          gqG - wrap paragraphs from here to the end of the buffer

          Bowie
        • Piet Delport
          ... Using this will lead to ugly MS Outlook-style wrapping, as in: Hippogriff, n.: An animal (now extinct) which was half horse and half griffin. The griffin
          Message 4 of 15 , Feb 26, 2003
          • 0 Attachment
            On Wed, 26 Feb 2003 at 17:43:44 +0100, Jürgen Krämer wrote:
            > A. S. Budden wrote:
            >>
            >> Is there anyway to take a file that has each paragraph on one line,
            >> and auto wrap it as if it had been typed with textwidth=72 on
            >> (observing word breaks etc).
            >
            > :set tw=72 | g/./normal gqq

            Using this will lead to ugly MS Outlook-style wrapping, as in:

            Hippogriff, n.:
            An animal (now extinct) which was half horse and half
            griffin. The
            griffin was itself a compound creature, half lion and half eagle.
            The
            hippogriff was actually, therefore, only one quarter eagle, which
            is two
            dollars and fifty cents in gold. The study of zoology is full of
            surprises.
            -- Ambrose Bierce, "The Devil's Dictionary"

            Much rather use gggqG, or some variant of it.

            --
            Piet Delport
            Today's subliminal thought is:
          • Jürgen Krämer
            ... no, because each line represents one paragraph. ... I suspected that each paragraph on one line might also mean that there is no separating empty line
            Message 5 of 15 , Feb 26, 2003
            • 0 Attachment
              Piet Delport wrote:
              > On Wed, 26 Feb 2003 at 17:43:44 +0100, Jürgen Krämer wrote:
              >
              >>A. S. Budden wrote:
              >>
              >>>Is there anyway to take a file that has each paragraph on one line,
              ^^^^^^^^^
              >>>and auto wrap it as if it had been typed with textwidth=72 on
              >>>(observing word breaks etc).
              >>
              >> :set tw=72 | g/./normal gqq
              >
              >
              > Using this will lead to ugly MS Outlook-style wrapping, as in:

              no, because each line represents one paragraph.

              > Much rather use gggqG, or some variant of it.

              I suspected that "each paragraph on one line" might also mean that there
              is no separating empty line between them. gggqG would then join all
              lines into one single block.

              Regards,
              Jürgen

              --
              Sometimes I think the surest sign that intelligent life exists elsewhere
              in the universe is that none of it has tried to contact us. (Calvin)
            • Pasi Orovuo
              Hi, Could someone possibly know why on earth does Vim6.3 set textwidth=78 each time I load a .txt file? I have: set textwidth=0 set tw=0 autocmd FileType text
              Message 6 of 15 , Feb 10, 2005
              • 0 Attachment
                Hi,

                Could someone possibly know why on earth does Vim6.3 set textwidth=78
                each time I load a .txt file?

                I have:
                set textwidth=0
                set tw=0
                autocmd FileType text setlocal textwidth=0

                in my ~/.vimrc but regardless of this I *always* get textwidth of 78
                whenever I load a .txt file.

                Regards,
                Pasi
              • Brett Kelly
                ... What do you want the textwidth to be? Do you want there to not be a limit? -- Brett Kelly inkedmn@inkedmn.com http://inkedmn.com:8000 GPG Fingerprint:
                Message 7 of 15 , Feb 10, 2005
                • 0 Attachment
                  Sometime around Fri, Feb 11, 2005 at 07:35:18AM +0200, Pasi Orovuo said:
                  >
                  > Hi,
                  >
                  > Could someone possibly know why on earth does Vim6.3 set textwidth=78
                  > each time I load a .txt file?
                  >
                  > I have:
                  > set textwidth=0
                  > set tw=0
                  > autocmd FileType text setlocal textwidth=0
                  >
                  > in my ~/.vimrc but regardless of this I *always* get textwidth of 78
                  > whenever I load a .txt file.
                  >
                  > Regards,
                  > Pasi
                  >

                  What do you want the textwidth to be? Do you want there to not be a limit?

                  --
                  Brett Kelly
                  inkedmn@...
                  http://inkedmn.com:8000
                  GPG Fingerprint: 30D5 98CB 9716 856E 4DBF 5960 A01E 2057 7E94 7AB1
                  GPG Public Key: http://inkedmn.com:8000/stuff/inkedmn.asc
                • Pasi Orovuo
                  ... textwidth=0 (text wraps at window/terminal edge) is what I m trying to achieve. Regards, Pasi
                  Message 8 of 15 , Feb 10, 2005
                  • 0 Attachment
                    Brett Kelly wrote:
                    > Sometime around Fri, Feb 11, 2005 at 07:35:18AM +0200, Pasi Orovuo said:
                    >
                    >>Hi,
                    >>
                    >>Could someone possibly know why on earth does Vim6.3 set textwidth=78
                    >>each time I load a .txt file?
                    >>
                    >>I have:
                    >>set textwidth=0
                    >>set tw=0
                    >>autocmd FileType text setlocal textwidth=0
                    >>
                    >>in my ~/.vimrc but regardless of this I *always* get textwidth of 78
                    >>whenever I load a .txt file.
                    >>
                    >>Regards,
                    >>Pasi
                    >>
                    >
                    >
                    > What do you want the textwidth to be? Do you want there to not be a limit?
                    >

                    textwidth=0 (text wraps at window/terminal edge) is what I'm trying to
                    achieve.

                    Regards,
                    Pasi
                  • Brett Kelly
                    ... I m wondering if it can be achieved using something like txt.vim (like you would any other programming language). Perhaps an expert can chime in on this?
                    Message 9 of 15 , Feb 10, 2005
                    • 0 Attachment
                      Sometime around Fri, Feb 11, 2005 at 08:59:27AM +0200, Pasi Orovuo said:
                      >
                      >
                      > Brett Kelly wrote:
                      > >Sometime around Fri, Feb 11, 2005 at 07:35:18AM +0200, Pasi Orovuo said:
                      > >
                      > >>Hi,
                      > >>
                      > >>Could someone possibly know why on earth does Vim6.3 set textwidth=78
                      > >>each time I load a .txt file?
                      > >>
                      > >>I have:
                      > >>set textwidth=0
                      > >>set tw=0
                      > >>autocmd FileType text setlocal textwidth=0
                      > >>
                      > >>in my ~/.vimrc but regardless of this I *always* get textwidth of 78
                      > >>whenever I load a .txt file.
                      > >>
                      > >>Regards,
                      > >>Pasi
                      > >>
                      > >
                      > >
                      > >What do you want the textwidth to be? Do you want there to not be a limit?
                      > >
                      >
                      > textwidth=0 (text wraps at window/terminal edge) is what I'm trying to
                      > achieve.
                      >
                      > Regards,
                      > Pasi
                      >
                      >

                      I'm wondering if it can be achieved using something like txt.vim (like you
                      would any other programming language). Perhaps an expert can chime in on
                      this?

                      --
                      Brett Kelly
                      inkedmn@...
                      http://inkedmn.com:8000
                      GPG Fingerprint: 30D5 98CB 9716 856E 4DBF 5960 A01E 2057 7E94 7AB1
                      GPG Public Key: http://inkedmn.com:8000/stuff/inkedmn.asc
                    • Antoine J. Mechelynck
                      ... It may depend on which file you are editing/viewing. For instance, most Vim help files (which are .txt files) have a modeline (q.v.) which sets (among
                      Message 10 of 15 , Feb 11, 2005
                      • 0 Attachment
                        Brett Kelly wrote:
                        > Sometime around Fri, Feb 11, 2005 at 08:59:27AM +0200, Pasi Orovuo said:
                        >
                        >>
                        >>Brett Kelly wrote:
                        >>
                        >>>Sometime around Fri, Feb 11, 2005 at 07:35:18AM +0200, Pasi Orovuo said:
                        >>>
                        >>>
                        >>>>Hi,
                        >>>>
                        >>>>Could someone possibly know why on earth does Vim6.3 set textwidth=78
                        >>>>each time I load a .txt file?
                        >>>>
                        >>>>I have:
                        >>>>set textwidth=0
                        >>>>set tw=0
                        >>>>autocmd FileType text setlocal textwidth=0
                        >>>>
                        >>>>in my ~/.vimrc but regardless of this I *always* get textwidth of 78
                        >>>>whenever I load a .txt file.
                        >>>>
                        >>>>Regards,
                        >>>>Pasi
                        >>>>
                        >>>
                        >>>
                        >>>What do you want the textwidth to be? Do you want there to not be a limit?
                        >>>
                        >>
                        >>textwidth=0 (text wraps at window/terminal edge) is what I'm trying to
                        >>achieve.
                        >>
                        >>Regards,
                        >>Pasi
                        >>
                        >>
                        >
                        >
                        > I'm wondering if it can be achieved using something like txt.vim (like you
                        > would any other programming language). Perhaps an expert can chime in on
                        > this?
                        >
                        It may depend on which file you are editing/viewing. For instance, most
                        Vim help files (which are .txt files) have a "modeline" (q.v.) which
                        sets (among other things) tw=78.

                        Also, I notice that there is no automatic filetype detection for .txt files

                        You (Pasi) might try the following (paths are given for Unix; for
                        Windows replace ~/.vim by [in Vim parlance] either ~/vimfiles or, if
                        $HOME is not properly set, $VIM/vimfiles):

                        ----- ~/.vim/filetype.vim
                        augroup filetypedetect
                        " there may be other autocommands here
                        autocmd BufRead,BufNewFile *.txt setf text
                        " there may be other autocommands here
                        augroup END
                        ----- ~/.vim/after/ftplugin/text.vim
                        setlocal tw=0
                        ----- end

                        The above will avoid breaking lines as you type (which is what tw=0
                        means). To wrap text at the edge of the Vim screen, add to your vimrc:

                        set wrap

                        If, in addition, you want long lines to be wrapped at a word boundary
                        (rather than exactly at the window's edge even in the middle of a word)
                        then also add:

                        set linebreak

                        The latter two options govern only where long lines are wrapped
                        on-screen, they do _not_ insert an actual line break into the file. To
                        apply these settings _only_ to .txt files, put those two commands into
                        the text.vim ft-plugin described above (instead of in the vimrc),
                        replacing set by setlocal.

                        HTH,
                        Tony.
                      • Antony Scriven
                        ... In addition to Tony s explanation of how to set up filetype detection for text files, you may wish to consider removing t from formatoptions . This
                        Message 11 of 15 , Feb 11, 2005
                        • 0 Attachment
                          Pasi Orovuo:

                          | Could someone possibly know why on earth does Vim6.3 set
                          | textwidth=78 each time I load a .txt file?
                          |
                          | I have:
                          | set textwidth=0
                          | set tw=0
                          | autocmd FileType text setlocal textwidth=0
                          |
                          | in my ~/.vimrc but regardless of this I *always* get
                          | textwidth of 78 whenever I load a .txt file.

                          Antoine Mechelynck:

                          | Also, I notice that there is no automatic filetype
                          | detection for .txt files

                          In addition to Tony's explanation of how to set up filetype
                          detection for text files, you may wish to consider removing
                          't' from 'formatoptions'. This means that vim will not
                          insert newlines at the 'textwidth' and you will get the
                          wrapping you want. But you will still be able to format the
                          text according to 'textwidth' with the gq command. (Note
                          that if 'tw' is zero, gq will still work according to the
                          rules in :help gq).

                          Antony
                        • Alejandro López-Valencia
                          ... Are you sourcing $VIMRUNTIME/vimrc_example.vim? Because that would explain the textwidth settings (read the file to see why). If you are not doing it
                          Message 12 of 15 , Feb 11, 2005
                          • 0 Attachment
                            Pasi Orovuo wrote:

                            >
                            > Hi,
                            >
                            > Could someone possibly know why on earth does Vim6.3 set textwidth=78
                            > each time I load a .txt file?
                            >
                            > I have:
                            > set textwidth=0
                            > set tw=0
                            > autocmd FileType text setlocal textwidth=0
                            >
                            > in my ~/.vimrc but regardless of this I *always* get textwidth of 78
                            > whenever I load a .txt file.
                            >
                            Are you sourcing $VIMRUNTIME/vimrc_example.vim? Because that would
                            explain the textwidth settings (read the file to see why). If you are
                            not doing it explicitly, check the configuration files that were
                            installed by your OS distribution. This is a common problem with Linux
                            distros, and RedHat/Fedora is particularly infamous for this.
                          • Pasi Orovuo
                            ... Thanks for the advice everyone! I tried Tony s suggestions but there was no change in vim s linewrapping behavior. I did get filetype=text and syntax=text,
                            Message 13 of 15 , Feb 11, 2005
                            • 0 Attachment
                              Antoine J. Mechelynck wrote:
                              > Brett Kelly wrote:
                              >
                              >> Sometime around Fri, Feb 11, 2005 at 08:59:27AM +0200, Pasi Orovuo said:
                              >>
                              >>>
                              >>> Brett Kelly wrote:
                              >>>
                              >>>> Sometime around Fri, Feb 11, 2005 at 07:35:18AM +0200, Pasi Orovuo
                              >>>> said:
                              >>>>
                              >>>>
                              >>>>> Hi,
                              >>>>>
                              >>>>> Could someone possibly know why on earth does Vim6.3 set
                              >>>>> textwidth=78 each time I load a .txt file?
                              >>>>>
                              >>>>> I have:
                              >>>>> set textwidth=0
                              >>>>> set tw=0
                              >>>>> autocmd FileType text setlocal textwidth=0
                              >>>>>
                              >>>>> in my ~/.vimrc but regardless of this I *always* get textwidth of
                              >>>>> 78 whenever I load a .txt file.
                              >>>>>
                              >>>>> Regards,
                              >>>>> Pasi
                              >>>>>
                              >>>>
                              >>>>
                              >>>> What do you want the textwidth to be? Do you want there to not be a
                              >>>> limit?
                              >>>>
                              >>>
                              >>> textwidth=0 (text wraps at window/terminal edge) is what I'm trying
                              >>> to achieve.
                              >>>
                              >>> Regards,
                              >>> Pasi
                              >>>
                              >>>
                              >>
                              >>
                              >> I'm wondering if it can be achieved using something like txt.vim (like
                              >> you
                              >> would any other programming language). Perhaps an expert can chime in on
                              >> this?
                              >>
                              > It may depend on which file you are editing/viewing. For instance, most
                              > Vim help files (which are .txt files) have a "modeline" (q.v.) which
                              > sets (among other things) tw=78.
                              >
                              > Also, I notice that there is no automatic filetype detection for .txt files
                              >
                              > You (Pasi) might try the following (paths are given for Unix; for
                              > Windows replace ~/.vim by [in Vim parlance] either ~/vimfiles or, if
                              > $HOME is not properly set, $VIM/vimfiles):
                              >
                              > ----- ~/.vim/filetype.vim
                              > augroup filetypedetect
                              > " there may be other autocommands here
                              > autocmd BufRead,BufNewFile *.txt setf text
                              > " there may be other autocommands here
                              > augroup END
                              > ----- ~/.vim/after/ftplugin/text.vim
                              > setlocal tw=0
                              > ----- end
                              >
                              > The above will avoid breaking lines as you type (which is what tw=0
                              > means). To wrap text at the edge of the Vim screen, add to your vimrc:
                              >
                              > set wrap
                              >
                              > If, in addition, you want long lines to be wrapped at a word boundary
                              > (rather than exactly at the window's edge even in the middle of a word)
                              > then also add:
                              >
                              > set linebreak
                              >
                              > The latter two options govern only where long lines are wrapped
                              > on-screen, they do _not_ insert an actual line break into the file. To
                              > apply these settings _only_ to .txt files, put those two commands into
                              > the text.vim ft-plugin described above (instead of in the vimrc),
                              > replacing set by setlocal.
                              >
                              > HTH,
                              > Tony.
                              >
                              >

                              Thanks for the advice everyone!

                              I tried Tony's suggestions but there was no change in vim's linewrapping
                              behavior. I did get filetype=text and syntax=text, but still textwidth
                              was 78.

                              After looking into Alejandros idea about sourcing vimrc_example.vim
                              (which didn't happen), I found the following in /etc/vim/vimrc:

                              augroup gentoo
                              au!
                              * snip irrelevant lines *
                              " In text files, limit the width of text to 78 characters, but be careful
                              " that we don't override the user's setting.
                              autocmd BufNewFile,BufRead *.txt if &tw == 0 | set tw=78 | endif
                              * snip irrelevant lines *
                              augroup END

                              I really had no idea this could have been Gentoo specific. I do recall
                              that vim was updated a while back, though... Apparently it's been a
                              while since I've edited text files, as I failed to associate this with
                              the update.

                              Apparently there nevertheless is a bug in Gentoo vim ebuild, as the
                              comment above the line says "...but be careful that we don't override
                              the user's setting" which they do. :) By commenting that line out I get
                              expected behaviour.

                              Again, thanks for help everyone.

                              Regards,
                              Pasi
                            • shawn wilson
                              How do i disable text width for everything but .txt, and .tex and program comments? Is this possible? -- -- You received this message from the vim_use
                              Message 14 of 15 , Jul 3, 2013
                              • 0 Attachment
                                How do i disable text width for everything but .txt, and .tex and
                                program comments? Is this possible?

                                --
                                --
                                You received this message from the "vim_use" maillist.
                                Do not top-post! Type your reply below the text you are replying to.
                                For more information, visit http://www.vim.org/maillist.php

                                ---
                                You received this message because you are subscribed to the Google Groups "vim_use" group.
                                To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                                For more options, visit https://groups.google.com/groups/opt_out.
                              • Ben Fritz
                                ... Yes. formatoptions controls when automatic formatting is allowed. Consult the help. Be aware that some filetype plugins set this option for you, so you
                                Message 15 of 15 , Jul 3, 2013
                                • 0 Attachment
                                  On Wednesday, July 3, 2013 11:32:45 AM UTC-5, shawn wilson wrote:
                                  > How do i disable text width for everything but .txt, and .tex and
                                  >
                                  > program comments? Is this possible?

                                  Yes. 'formatoptions' controls when automatic formatting is allowed. Consult the help. Be aware that some filetype plugins set this option for you, so you may need to make use of the after/ftplugin directory, or a FileType autocmd, to set formatoptions as you like for specific filetypes.

                                  --
                                  --
                                  You received this message from the "vim_use" maillist.
                                  Do not top-post! Type your reply below the text you are replying to.
                                  For more information, visit http://www.vim.org/maillist.php

                                  ---
                                  You received this message because you are subscribed to the Google Groups "vim_use" group.
                                  To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
                                  For more options, visit https://groups.google.com/groups/opt_out.
                                Your message has been successfully submitted and would be delivered to recipients shortly.