Kartik Agaram wrote:

> I keep my notes in a text file in vim. Often I paste in URLs into my notes,
> but the URLs are long. The way textwidth works, they get shoved into the
> next line, leaving the original line woefully short. For years now I've
> been manually joining lines in this situation. It just looks better;
> compare the lines at the center of the screen in:
> 
> [image: Inline image 1]
> 
> and:
> 
> [image: Inline image 2]
> 
> I get a 'ragged right edge' anyway with textwidth; I'm happy to have it
> overflow a little bit just like it can underflow.
> 
> So I've been poking around vim's sources. What I want to build is a way to
> say, "don't break lines left of this column". After some investigation it
> seems like this is the place to modify, in internal_format():
> 
> $ hg diff
> diff -r dde8ff798ed9 src/edit.c
> --- a/src/edit.c    Sat Aug 30 18:10:19 2014 +0200
> +++ b/src/edit.c    Wed Sep 03 09:31:17 2014 -0700
> @@ -6223,7 +6223,8 @@
>          cc = c;
>          else
>          cc = gchar_cursor();
> -        if (WHITECHAR(cc))
> +        if (WHITECHAR(cc)
> +                    && curwin->w_cursor.col >= 70)
>          {
>          /* remember position of blank just before text */
>          end_col = curwin->w_cursor.col;
> 
> This seems to work for me, but I know that's a low bar :) Does it seem on
> the right track? My todo list currently looks like this:
> 1. Fix the multibyte branch below.
> 2. Turn the hardcoded constant into a vim option (maybe mintextwidth?)
>  and add docs for it.
> 
> Am I missing anything else? Can others (Christian Brabandt? Hi! :) think of
> interactions with other options that also affect formatting?

It's true that when you have a very long word you may get a very short
line before it, e.g. when you write "look here: <very long URL>" you may
end up with a line only containing "here:".

It would require setting an option to the minimal line length before
inserting a break.  Not only in edit.c but also when text is formatted.


-- 
>From "know your smileys":
 :-E    Has major dental problems

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
-- 
You received this message from the "vim_dev" 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_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Raspunde prin e-mail lui