>
> opening an existing file that have lines longer than the screen width, how do
> i format the file for easy reading.
>
> i think that the options 'textwidth' and 'wrapmargin' are effective only
> while editing the file and adding _new_ lines...not for existing lines which
> will not change whatever value you assign to those options.Am I right?
It depends on whether you want re-wrapping that inserts newlines,
or if you just want to visually wrap the lines without effecting
their contents (by adding newlines)
For the former, you can use
:set tw=65 " whatever you want
:g/^/norm gqq
to reformat each line to the adjusted 'tw' setting. Note that
this will not *join* lines as "gqip" would. You could adjust the
:global command to something like
:g/^\n\</norm gq}
(untested) to reformat each empty-line-separated paragraph.
For the latter, you can
:set wrap
and optionally
:set linebreak
to get smart line-breaking that breaks at word-boundaries instead
of at the column-boundary.
Hope this helps,
-tim
--
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
No comments:
Post a Comment