Subject: Re: [sup-talk] vim text wrapping

From: Bruno d'Arcangeli <[email-masked]>
Date: Thu, 17 Mar 2011 18:46:55 +0100

Le 17/03/2011 à 17:23, pancho horrillo a écrit:
> If you want Vim to reformat the text when you edit it, just run :set
> formatoptions+=a or add it to your vimrc, etc.  gq}     reflow till
> the end of the paragraph gqap    reflow the whole paragraph

Cool. Last time i've asked for this on a list, i was flamed.  I've added
this to my .vimrc:
au BufRead /tmp/sup.* set formatoptions+=a
-- 
Bruno d'Arcangeli
_______________________________________________
sup-talk mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk

---

From: Amadeusz Żołnowski <[email-masked]>
Date: Thu, 17 Mar 2011 17:12:13 +0100

Excerpts from Philippe LeCavalier's message of Thu Mar 17 15:26:51 +0100 2011:
> This is more of a vim question than it is a sup one but I'm not a
> member of the vim list so I thought I'd ask you guys first.
> 
> Since I don't write very well I always end up making changes while
> re-reading myself. When I edit a line Vim doesn't wrap anymore like it
> did when I first typed the text. So all the lines I've edited aren't
> wrapped like the others. It can make reading my mail challenging at
> times.
> 
> Perhaps I'm misunderstanding how to properly edit text in vim?

In visual mode select blocks you'd like to fix and type 'gq' command. Is
it that you'd like to achieve?
-- 
Amadeusz Żołnowski

PGP key fpr: C700 CEDE 0C18 212E 49DA  4653 F013 4531 E1DB FAB5
_______________________________________________
sup-talk mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk

---

From: Peter Lewis <[email-masked]>
Date: Thu, 17 Mar 2011 16:05:01 +0000

Hi,

> wrapped like the others. It can make reading my mail challenging at

I've not managed to get vim to do this automatically (I haven't tried much
though). What I usually do is, once I've re-edited a paragraph and it has some
overflowing lines, go to that paragraph in Normal mode and do:

vip  (to select the whole paragraph), then
gq   (to rewrap the selected text).

HTH,

Pete.

---

From: Ico Doornekamp <[email-masked]>
Date: Thu, 17 Mar 2011 17:19:29 +0100

> Perhaps I'm misunderstanding how to properly edit text in vim?

I guess this can be called a 'feature' of vim, Bram probably has a good
reason for making it behave as it does. 

As far as I know, wrapping only occurs when you are in insert mode
adding text at the end of the current line, but not when you are
inserting text in the middle of a line.

My own habit is to just add or remove the text as a go, and hit the key
sequence 'gwap' to clean up the mess, which means so much as 'reformat
(rewrap) the current paragraph'. The vim help for 'gw':

  gw{motion}    Format the lines that {motion} moves over.  Similar to
                |gq| but puts the cursor back at the same position in
                the text.  However, 'formatprg' and 'formatexpr' are
                not used.  {not in Vi}

where {motion} would be 'ap', meaning 'a paragraph'.

It looks kind of cumbersome in the beginning, but I'm very much used to
it and don't even think about it anymore.

-- 
:wq
^X^Cy^K^X^C^C^C^C

---

From: Matthieu Rakotojaona <[email-masked]>
Date: Thu, 17 Mar 2011 17:47:38 +0100

> wrapped like the others. It can make reading my mail challenging at

Just like everyone said, I use

gqap

in the middle of a paragraph i'd like to reformat. Also of note, I set
my formatoptions like this :

:set formatoptions = tcq

which brings me more or less what I want. Check the man (:he
formatoptions) to see the different options for the formating.
_______________________________________________
sup-talk mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk

---

From: Philippe LeCavalier <[email-masked]>
Date: Thu, 17 Mar 2011 10:26:51 -0400

Hi All.

-- 
Thanks,
Phil

---

From: Philippe LeCavalier <[email-masked]>
Date: Thu, 17 Mar 2011 14:14:46 -0400

> it and don't even think about it anymore.
That's pretty much what I expected since I had already visited the
options for textwidth and the like. I can certainly get used to a kbd
sequence since I expect that sort of thing when using Vim. In fact,
since adopting sup my hands don't really leave the keyboard.

However what James mentioned about formatoptions might alleviate that.
James, I add these types of things to my vim line in config.yaml rather
than my rc file. I to don't always want wrapping at 72 and the like. But
I do always want this in sup.
-- 
Thanks,
Phil
_______________________________________________
sup-talk mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk

---

From: Paul Grove <[email-masked]>
Date: Thu, 17 Mar 2011 15:33:32 +0000

The answer to this question is in my interest also.

---

From: pancho horrillo <[email-masked]>
Date: Thu, 17 Mar 2011 17:23:58 +0100

> Hi All.
Hi there.

> wrapped like the others. It can make reading my mail challenging at
For the sake of others:
If you want Vim to fold lines as you newly write them, just run
:set textwidth=72  # set tw=72 for short

If you want Vim to reformat the text when you edit it, just run
:set formatoptions+=a
or add it to your vimrc, etc.

This is explained in Vim help,
:help textwidth
:help ins-textwidth
:help formatoptions
:help fo-table

If you don't want this to happen all the time (as I don't),
you can use the gq operator discretionally.
gq <movement>, e.g.:
gq}     reflow till the end of the paragraph
gqap    reflow the whole paragraph

> Perhaps I'm misunderstanding how to properly edit text in vim?
A minor tweak and you are done.

Hope that it helps.

Happy hacking,

-- 
pancho horrillo

To be conscious that
you are ignorant is a great step
to knowledge.

		Benjamin Disraeli

---

From: Erin Sheldon <[email-masked]>
Date: Thu, 17 Mar 2011 12:04:15 -0400

> Perhaps I'm misunderstanding how to properly edit text in vim?

You can have vim justify all the text in a paragraph.  I have these in
my .vimrc, which makes typing Q justify the text.

" n is for normal mode
nnoremap Q gqap
" v is for visual mode.
vnoremap Q gq

-- 
Erin Scott Sheldon
Brookhaven National Laboratory
_______________________________________________
sup-talk mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk

---

From: Philippe LeCavalier <[email-masked]>
Date: Fri, 18 Mar 2011 09:56:26 -0400

> I do always want this in sup.

Thought I'd post back after having lived with formatoptions+=a for a
day. This options is _really_ annoying. It's hard to explain, but
although it does what I wanted in that it automatically wraps text when
editing lines it also drove me nuts because it prevents you from
inserting linebreaks -something I do regularly. So I'm back to just -c
'set textwidth=72' and will employ the gwap kbd sequence.

---

From: James Taylor <[email-masked]>
Date: Thu, 17 Mar 2011 12:10:57 -0400

I use gqap constantly while writing email and other prose in vim.

(:help gq gives you the following)

"""
gqgq                                                    gqgq gqq
gqq                     Format the current line.  With a count format that
                        many lines.  {not in Vi}

                                                        v_gq
{Visual}gq              Format the highlighted text.  (for {Visual} see
                        Visual-mode).  {not in Vi}

                                                        gw
gw{motion}              Format the lines that {motion} moves over.  Similar to
                        gq but puts the cursor back at the same position in
                        the text.  However, 'formatprg' and 'formatexpr' are
                        not used.  {not in Vi}

gwgw                                                    gwgw gww
gww                     Format the current line as with "gw".  {not in Vi}

                                                        v_gw
{Visual}gw              Format the highlighted text as with "gw".  (for
                        {Visual} see Visual-mode).  {not in Vi}

Example: To format the current paragraph use:                   gqap  >
        gqap

The "gq" command leaves the cursor in the line where the motion command takes
the cursor.  This allows you to repeat formatting repeated with ".".  This
works well with "gqj" (format current and next line) and "gq}" (format until
end of paragraph).  Note: When 'formatprg' is set, "gq" leaves the cursor on
the first formatted line (as with using a filter command).

If you want to format the current paragraph and continue where you were, use: >
        gwap
If you always want to keep paragraphs formatted you may want to add the 'a'
flag to 'formatoptions'.  See auto-format.
"""

>> Perhaps I'm misunderstanding how to properly edit text in vim?

-- jt

James Taylor, Assistant Professor, Biology / Computer Science, Emory University

---

From: Stanislav Ochotnicky <[email-masked]>
Date: Thu, 17 Mar 2011 16:14:13 +0100

> member of the vim list so I thought I'd ask you guys first.

Really not a sup question at all, but I have no problem trying to
answer. Others might feel different though :-)

> wrapped like the others. It can make reading my mail challenging at

How about "gqq"? Also "set nopaste" and "set textwidth=72" should be
of help most of the time.

> Perhaps I'm misunderstanding how to properly edit text in vim?

Nah, vim might look like a simple editor but it has more features than
most people would believe :-)

--
Stanislav Ochotnicky <[email-masked]>
Software Engineer - Base Operating Systems Brno

PGP: 7B087241
Red Hat Inc.                               http://cz.redhat.com
_______________________________________________
sup-talk mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk

---

From: Tyberius Prime <[email-masked]>
Date: Thu, 17 Mar 2011 16:40:52 +0100

Hey, 

I usually just hit gqap on every paragraph that looks out of line, and vim
rewraps it for me.

See http://vimdoc.sourceforge.net/htmldoc/change.html#gq

So long,
Tyberius Prime

---

From: Bruno d'Arcangeli <[email-masked]>
Date: Thu, 17 Mar 2011 16:52:15 +0100

> Perhaps I'm misunderstanding how to properly edit text in vim?
 
I'm not a vim expert but simple user and i think that you can't. I've
seen many people asking for this on different vim list/forum. It's
apparently a vi functionality and can't be changed.
-- 
Bruno d'Arcangeli
_______________________________________________
sup-talk mailing list
[email-masked]
http://rubyforge.org/mailman/listinfo/sup-talk