textwidth problem

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

textwidth problem

jkilbour
I have a file with a very long line. I
:set tw=85

but I still cannot read all the content beyond the right side of my
window. The tw=85 shows up when I do
:set




Reply | Threaded
Open this post in threaded view
|

Re: textwidth problem

Sebastian Korten
Hi there,
> I have a file with a very long line. I
> :set tw=85
> but I still cannot read all the content beyond the right side of my
> window. The tw=85 shows up when I do
The tw (textwidt) parameter is used only when you insert text.
A linebreak is inserted at the first whitespace after you have reached (in
your case) 85 characters.

If you just want to read the file, you can set wrap (:set wrap) which will
break the line on the display but not in the actual text.

For those two options read the superb online help
:help tw
:help wrap

Hope that I helped,
Bass
Reply | Threaded
Open this post in threaded view
|

Re: textwidth problem

Tim Chase-2
In reply to this post by jkilbour
> I have a file with a very long line. I
> :set tw=85
>
> but I still cannot read all the content beyond the right side of my
> window. The tw=85 shows up when I do
> :set

Well, if you don't mind wrapping, simply

        :set wrap

which will *visually* wrap long lines (won't actually make
changes to the file).  For some visual cues that a line is
wrapped, you can monkey with the 'listchars' and 'list' options.

If you don't want them to wrap, buy a wider monitor, use a
smaller font, or increase your window size :*)

If you want to actually force lines to end at your 'tw' setting,
you can use

        gggqG

which goes to the top of your document, and reformats to the
bottom of the document.

Just a few ideas.

-tim




Reply | Threaded
Open this post in threaded view
|

Re: textwidth problem

jkilbour
In reply to this post by Sebastian Korten
Something is still not working; I
:set wrap without visible effect.

I created the file by
grep "string" onefile > vimfile
and so see the text in the command window with
grep "string" onefile

Only about half the file is visible. It actually looks like my vertical
scroll is having a problem; If I could scroll I could probably see the
file. The scrollbars are visible, but take up the whole window no matter
how I resize it.


> Hi there,
>> I have a file with a very long line. I
>> :set tw=85
>> but I still cannot read all the content beyond the right side of my
>> window. The tw=85 shows up when I do
> The tw (textwidt) parameter is used only when you insert text.
> A linebreak is inserted at the first whitespace after you have reached
> (in  your case) 85 characters.
>
> If you just want to read the file, you can set wrap (:set wrap) which
> will  break the line on the display but not in the actual text.
>
> For those two options read the superb online help
> :help tw
> :help wrap
>
> Hope that I helped,
> Bass



Reply | Threaded
Open this post in threaded view
|

Re: textwidth problem

Charles E Campbell Jr
In reply to this post by Tim Chase-2
Tim Chase wrote:

>> I have a file with a very long line. I
>> :set tw=85
>>
>> but I still cannot read all the content beyond the right side of my
>> window. The tw=85 shows up when I do
>> :set
>
>
> Well, if you don't mind wrapping, simply
>
> :set wrap
> ...
> If you don't want them to wrap, buy a wider monitor, use a smaller
> font, or increase your window size :*)

In addition to TimC's WoW (Words of Wisdom!):

If you don't like wrapping, :set nowrap
but be prepared to have to occasionally use zL and zH (or lean on the hl
keys).
I like :set ve=all with nowrap.

Regards,
Chip Campbell
Reply | Threaded
Open this post in threaded view
|

Re: textwidth problem

Gary Johnson
In reply to this post by jkilbour
On 2005-09-09, [hidden email] wrote:

> Something is still not working; I
> :set wrap without visible effect.
>
> I created the file by
> grep "string" onefile > vimfile
> and so see the text in the command window with
> grep "string" onefile
>
> Only about half the file is visible. It actually looks like my vertical
> scroll is having a problem; If I could scroll I could probably see the
> file. The scrollbars are visible, but take up the whole window no matter
> how I resize it.

Vim is intended to be used to view and modify text that has been
loaded into one of its buffers.  It appears that you are trying to
view the output of a shell command that you executed from the vim
command line.  The wrap and textwidth settings have no effect on the
display of a shell command's output, nor can you use any of vim's
commands or the scrollbar to scroll through that output.

A better way to view the contents of vimfile would be to simply open
it with vim.  If you already have some other file open and you don't
want to lose that work, you can open vimfile in a new buffer/window:

    :split vimfile

Alternatively, you could create a new buffer/window,

    :new

and read the output of your grep command into that buffer/window,

    :r !grep "string" onefile

HTH,
Gary

--
Gary Johnson                 | Agilent Technologies
[hidden email]     | Wireless Division
                             | Spokane, Washington, USA
Reply | Threaded
Open this post in threaded view
|

Re: textwidth problem

jkilbour


> On 2005-09-09, [hidden email] wrote:
>> Something is still not working; I
>> :set wrap without visible effect.
>>
>> I created the file by
>> grep "string" onefile > vimfile
>> and so see the text in the command window with
>> grep "string" onefile
>>
>> Only about half the file is visible. It actually looks like my
>> vertical scroll is having a problem; If I could scroll I could
>> probably see the file. The scrollbars are visible, but take up the
>> whole window no matter how I resize it.
>
> Vim is intended to be used to view and modify text that has been
> loaded into one of its buffers.  It appears that you are trying to  view
> the output of a shell command that you executed from the vim  command
> line.  The wrap and textwidth settings have no effect on the  display of
> a shell command's output, nor can you use any of vim's  commands or the
> scrollbar to scroll through that output.
>
> A better way to view the contents of vimfile would be to simply open  it
> with vim.  If you already have some other file open and you don't  want
> to lose that work, you can open vimfile in a new buffer/window:
>
>     :split vimfile
>
> Alternatively, you could create a new buffer/window,
>
>     :new
>
> and read the output of your grep command into that buffer/window,
>
>     :r !grep "string" onefile
>
> HTH,
> Gary

Thanks Gary, but I was not clear; I did not use a command shell obtained
from the vim command line; I just used a regular command shell. The
embarrassing thing is I can see it in Notepad. I also opened the file
which cntained this offending line, and see the same behaviour in VIM.


Reply | Threaded
Open this post in threaded view
|

Re: textwidth problem

A.J.Mechelynck
In reply to this post by jkilbour
----- Original Message -----
From: <[hidden email]>
To: <[hidden email]>
Sent: Friday, September 09, 2005 9:03 PM
Subject: textwidth problem


>I have a file with a very long line. I
> :set tw=85
>
> but I still cannot read all the content beyond the right side of my
> window. The tw=85 shows up when I do
> :set

I have some files with very long lines; some of them are too big to fit into
my narrow split window. I use

    :set wrap tw=0 list listchars=tab:\ \ ,eol:? display=lastline

'wrap' on: lines longer than the window width will wrap to a second (, a
third, etc.) screen line
'tw' 0: don't add hard breaks based on line length
'list' on: show 'listchars' characters
'listchars'
    tab:\ \
        show hard tbs as usual, by one to eight spaces
    eol:?
        show the end of a file line by a blue ?
'display' "lastline":
    even if the last line in a window overflows at the bottom, show as much
of it as fits in the window with @@@ at bottom right, instead of replacing
it all with one or more lines showing only @ at left.

That way, if a line is longer than the window width, it overflows to a
second (and possibly a third, etc.) screen line. The ends-of-lines, shown by
blue ? signs, allow me to see easily where a "file line" ends. Also (with
display=lastline) if the last line in a window overflows at bottom, as much
of it will be shown as fits in the window, with @@@ in blue at bottom right,
rather than replacing it by one or more screen lines consisting only of a
blue @ at left.

YMMV.


'textwidth' is used to insert hard line breaks as you type a line that
exceeds the limit, to break lines when reformatting with gq , etc.



Best regards,
Tony.


Reply | Threaded
Open this post in threaded view
|

Re[2]: textwidth problem

Alan G Isaac
In reply to this post by Sebastian Korten
On Fri, 9 Sep 2005, Sebastian Korten apparently wrote:
> The tw (textwidt) parameter is used only when you insert
> text. ...  If you just want to read the file, you can set
> wrap (:set wrap) which will break the line on the display
> but not in the actual text.

This reminds me of an enhancement wish.
I wish wrap margin could be used with wrap in the way one
would guess from the names:
i.e., it would determine a right margin for *visual*
wrapping (i.e., no EOL insertion).
(Does anyone currently 'set wrap' and then use wrapmargin to
get some desired effect?  If so, what is it?  If not, would
this not be a sensible change in behavior?)

Cheers,
Alan Isaac



Reply | Threaded
Open this post in threaded view
|

Re: textwidth problem

Gary Johnson
In reply to this post by jkilbour
On 2005-09-09, [hidden email] wrote:

> > On 2005-09-09, [hidden email] wrote:
> >> Something is still not working; I
> >> :set wrap without visible effect.
> >>
> >> I created the file by
> >> grep "string" onefile > vimfile
> >> and so see the text in the command window with
> >> grep "string" onefile
> >>
> >> Only about half the file is visible. It actually looks like my
> >> vertical scroll is having a problem; If I could scroll I could
> >> probably see the file. The scrollbars are visible, but take up the
> >> whole window no matter how I resize it.
> >
> > Vim is intended to be used to view and modify text that has been
> > loaded into one of its buffers.  It appears that you are trying to  view
> > the output of a shell command that you executed from the vim  command
> > line.  The wrap and textwidth settings have no effect on the  display of
> > a shell command's output, nor can you use any of vim's  commands or the
> > scrollbar to scroll through that output.
> >
> > A better way to view the contents of vimfile would be to simply open  it
> > with vim.  If you already have some other file open and you don't  want
> > to lose that work, you can open vimfile in a new buffer/window:
> >
> >     :split vimfile
> >
> > Alternatively, you could create a new buffer/window,
> >
> >     :new
> >
> > and read the output of your grep command into that buffer/window,
> >
> >     :r !grep "string" onefile
> >
> > HTH,
> > Gary
>
> Thanks Gary, but I was not clear; I did not use a command shell obtained
> from the vim command line; I just used a regular command shell. The
> embarrassing thing is I can see it in Notepad. I also opened the file
> which cntained this offending line, and see the same behaviour in VIM.

I think I'm beginning to understand the problem, but I'm still not
sure.  Just how long is this offending line?  If it is longer than
the product of the number of rows and columns in your vim window, I
can see how you would have problems viewing the end of the line even
with 'wrap' set.

Have you tried gj and gk to move through the wrapped line?

Vim does have some limitations when it comes to viewing very long
lines that Notepad doesn't have.  Specifically, vim can't display
the end of a very long line and the beginning of the next line at
the same time.

Regards,
Gary

--
Gary Johnson                 | Agilent Technologies
[hidden email]     | Wireless Division
                             | Spokane, Washington, USA
Reply | Threaded
Open this post in threaded view
|

Re[2]: textwidth problem

Alan G Isaac
On Fri, 9 Sep 2005, Gary Johnson apparently wrote:
> I think I'm beginning to understand the problem, but I'm still not
> sure.  Just how long is this offending line?  If it is longer than
> the product of the number of rows and columns in your vim window, I
> can see how you would have problems viewing the end of the line even
> with 'wrap' set.

In that case
set display=lastline
might help.

Cheers,
Alan Isaac



Reply | Threaded
Open this post in threaded view
|

Re: textwidth problem

A.J.Mechelynck
In reply to this post by A.J.Mechelynck
----- Original Message -----
From: <[hidden email]>
To: <[hidden email]>
Sent: Friday, September 09, 2005 10:20 PM
Subject: Re: textwidth problem


>
>
>> ----- Original Message -----
>> From: <[hidden email]>
>> To: <[hidden email]>
>> Sent: Friday, September 09, 2005 9:03 PM
>> Subject: textwidth problem
>>
>>
>>>I have a file with a very long line. I
>>> :set tw=85
>>>
>>> but I still cannot read all the content beyond the right side of my
>>> window. The tw=85 shows up when I do
>>> :set
>>
>> I have some files with very long lines; some of them are too big to fit
>> into  my narrow split window. I use
>>
>>     :set wrap tw=0 list listchars=tab:\ \ ,eol:? display=lastline
>>
>> 'wrap' on: lines longer than the window width will wrap to a second (, a
>>  third, etc.) screen line
>> 'tw' 0: don't add hard breaks based on line length
>> 'list' on: show 'listchars' characters
>> 'listchars'
>>     tab:\ \
>>         show hard tbs as usual, by one to eight spaces
>>     eol:?
>>         show the end of a file line by a blue ?
>> 'display' "lastline":
>>     even if the last line in a window overflows at the bottom, show as
>> much
>> of it as fits in the window with @@@ at bottom right, instead of
>> replacing  it all with one or more lines showing only @ at left.
>>
>> That way, if a line is longer than the window width, it overflows to a
>> second (and possibly a third, etc.) screen line. The ends-of-lines,
>> shown by  blue ? signs, allow me to see easily where a "file line" ends.
>> Also (with  display=lastline) if the last line in a window overflows at
>> bottom, as much  of it will be shown as fits in the window, with @@@ in
>> blue at bottom right,  rather than replacing it by one or more screen
>> lines consisting only of a  blue @ at left.
>>
>
> Something odd is up, becuase this is not working for me. I added
>
> set wrap
> set tw=0
> set list listchars=tab:\ \ ,eol:? display=lastline
>
> to my _vimrc, restarted and reloaded the file, wiht no change. The
> vertical scroll bar has no "space", though the file extends below the
> window. The file also extends to the right of the window.

If the window is very narrow top-to-bottom (one line maybe) the scrollbar at
right may have just the up and down arrows but not the thumb; normally
however, there should be also a moving thumb.

With 'wrap', there should be no horizontal scrollbar, since long file lines
should be shown on several screen lines. I don't know what is wrong.

What happens if you do

    :verbose set wrap?

(with the question mark)?


Best regards,
Tony.


Reply | Threaded
Open this post in threaded view
|

Re: textwidth problem

jkilbour


> ----- Original Message -----
> From: <[hidden email]>
> To: <[hidden email]>
> Sent: Friday, September 09, 2005 10:20 PM
> Subject: Re: textwidth problem
>
>
>>
>>
>>> ----- Original Message -----
>>> From: <[hidden email]>
>>> To: <[hidden email]>
>>> Sent: Friday, September 09, 2005 9:03 PM
>>> Subject: textwidth problem
>>>
>>>
>>>>I have a file with a very long line. I
>>>> :set tw=85
>>>>
>>>> but I still cannot read all the content beyond the right side of my
>>>> window. The tw=85 shows up when I do
>>>> :set
>>>
>>> I have some files with very long lines; some of them are too big to
>>> fit into  my narrow split window. I use
>>>
>>>     :set wrap tw=0 list listchars=tab:\ \ ,eol:? display=lastline
>>>
>>> 'wrap' on: lines longer than the window width will wrap to a second
>>> (, a
>>>  third, etc.) screen line
>>> 'tw' 0: don't add hard breaks based on line length
>>> 'list' on: show 'listchars' characters
>>> 'listchars'
>>>     tab:\ \
>>>         show hard tbs as usual, by one to eight spaces
>>>     eol:?
>>>         show the end of a file line by a blue ?
>>> 'display' "lastline":
>>>     even if the last line in a window overflows at the bottom, show
>>> as
>>> much
>>> of it as fits in the window with @@@ at bottom right, instead of
>>> replacing  it all with one or more lines showing only @ at left.
>>>
>>> That way, if a line is longer than the window width, it overflows to
>>> a second (and possibly a third, etc.) screen line. The ends-of-lines,
>>> shown by  blue ? signs, allow me to see easily where a "file line"
>>> ends. Also (with  display=lastline) if the last line in a window
>>> overflows at bottom, as much  of it will be shown as fits in the
>>> window, with @@@ in blue at bottom right,  rather than replacing it
>>> by one or more screen lines consisting only of a  blue @ at left.
>>>
>>
>> Something odd is up, becuase this is not working for me. I added
>>
>> set wrap
>> set tw=0
>> set list listchars=tab:\ \ ,eol:? display=lastline
>>
>> to my _vimrc, restarted and reloaded the file, wiht no change. The
>> vertical scroll bar has no "space", though the file extends below the
>> window. The file also extends to the right of the window.
>
> If the window is very narrow top-to-bottom (one line maybe) the
> scrollbar at  right may have just the up and down arrows but not the
> thumb; normally  however, there should be also a moving thumb.
>
> With 'wrap', there should be no horizontal scrollbar, since long file
> lines  should be shown on several screen lines. I don't know what is
> wrong.
>
> What happens if you do
>
>     :verbose set wrap?
>
> (with the question mark)?
>


I think I figured out what is happening. For a very long line, you cannot
use the scrollbar in a gui window to see the part not shown in the window.
You can use the "l" key and other movement commands ($, etc) to see the
rest of the file. I had thought that the scroll bar would let me see the
rest, but now that I understand, I don't have a problem (how is that like
the rest of my life :) )?

Thank you for your help.


Reply | Threaded
Open this post in threaded view
|

Re: textwidth problem

A.J.Mechelynck
----- Original Message -----
From: <[hidden email]>
To: <[hidden email]>
Sent: Friday, September 09, 2005 11:25 PM
Subject: Re: textwidth problem


>
>
>> ----- Original Message -----
>> From: <[hidden email]>
>> To: <[hidden email]>
>> Sent: Friday, September 09, 2005 10:20 PM
>> Subject: Re: textwidth problem
>>
>>
>>>
>>>
>>>> ----- Original Message -----
>>>> From: <[hidden email]>
>>>> To: <[hidden email]>
>>>> Sent: Friday, September 09, 2005 9:03 PM
>>>> Subject: textwidth problem
>>>>
>>>>
>>>>>I have a file with a very long line. I
>>>>> :set tw=85
>>>>>
>>>>> but I still cannot read all the content beyond the right side of my
>>>>> window. The tw=85 shows up when I do
>>>>> :set
>>>>
>>>> I have some files with very long lines; some of them are too big to
>>>> fit into  my narrow split window. I use
>>>>
>>>>     :set wrap tw=0 list listchars=tab:\ \ ,eol:? display=lastline
>>>>
>>>> 'wrap' on: lines longer than the window width will wrap to a second
>>>> (, a
>>>>  third, etc.) screen line
>>>> 'tw' 0: don't add hard breaks based on line length
>>>> 'list' on: show 'listchars' characters
>>>> 'listchars'
>>>>     tab:\ \
>>>>         show hard tbs as usual, by one to eight spaces
>>>>     eol:?
>>>>         show the end of a file line by a blue ?
>>>> 'display' "lastline":
>>>>     even if the last line in a window overflows at the bottom, show
>>>> as
>>>> much
>>>> of it as fits in the window with @@@ at bottom right, instead of
>>>> replacing  it all with one or more lines showing only @ at left.
>>>>
>>>> That way, if a line is longer than the window width, it overflows to
>>>> a second (and possibly a third, etc.) screen line. The ends-of-lines,
>>>> shown by  blue ? signs, allow me to see easily where a "file line"
>>>> ends. Also (with  display=lastline) if the last line in a window
>>>> overflows at bottom, as much  of it will be shown as fits in the
>>>> window, with @@@ in blue at bottom right,  rather than replacing it
>>>> by one or more screen lines consisting only of a  blue @ at left.
>>>>
>>>
>>> Something odd is up, becuase this is not working for me. I added
>>>
>>> set wrap
>>> set tw=0
>>> set list listchars=tab:\ \ ,eol:? display=lastline
>>>
>>> to my _vimrc, restarted and reloaded the file, wiht no change. The
>>> vertical scroll bar has no "space", though the file extends below the
>>> window. The file also extends to the right of the window.
>>
>> If the window is very narrow top-to-bottom (one line maybe) the
>> scrollbar at  right may have just the up and down arrows but not the
>> thumb; normally  however, there should be also a moving thumb.
>>
>> With 'wrap', there should be no horizontal scrollbar, since long file
>> lines  should be shown on several screen lines. I don't know what is
>> wrong.
>>
>> What happens if you do
>>
>>     :verbose set wrap?
>>
>> (with the question mark)?
>>
>
>
> I think I figured out what is happening. For a very long line, you cannot
> use the scrollbar in a gui window to see the part not shown in the window.
> You can use the "l" key and other movement commands ($, etc) to see the
> rest of the file. I had thought that the scroll bar would let me see the
> rest, but now that I understand, I don't have a problem (how is that like
> the rest of my life :) )?
>
> Thank you for your help.

If the line is longer by itself than the whole window, it will occupy the
window all by itself, and only the part with the cursor will be seen. You
might want to use mappings, for instance

    :map    <Up>    gk
    :map    <Down>    gj
    :imap    <Up>    <C-O>gk
    :imap    <Down>    <C-O>gj

so up-down arrow keys move the cursor by "screen" lines in both Normal and
Insert/Replace modes (jk in Normal mode will still move by "file" lines).
(type everything as shown, or use copy-paste to put it into your vimrc).


Best regards,
Tony.