Tuesday, December 3, 2013

Re: setting different tw= for different parts of file

On 2013-12-03 11:40, Konrad Delong wrote:
> I don't seem to be able to google it up. Is there a way of setting
> a different textwidth (tw=) for different parts of the file (eg.
> based on the highlight semantics)?
>
> My specific use case is Python code in which I would like to allow
> the import lines to extend the textwidth limit (and still
> automatically apply it to all other lines).

Short answer: no

Slightly longer answer: you can persuade Vim to have lines longer
than 'tw' as long as you don't insert/append/gq on those lines (or are
willing to re-join them after they re-wrap; though Vim makes that
easy).

More convoluted answer: you could write some sort of script/plugin
that manages lines that match "^\s*import" or
"^\s*from\s\+.*\s\+import\>" and

More PEP8 answer: don't do that. :-) Personally, this is the route I
choose, as I like to keep them one-per-line, alphabetically sorted
(well, dominantly sorted first by stdlib, then add-ons, then
project modules). It also makes VCS diffs neater. I'd rather see


import foo
import bar
+ import baz
import fred
import barney

than

- import foo, bar, fred, barney
+ import foo, bar, baz, fred, barney

where I have to pay attention to what changed rather than having it
obscured.

-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

---
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@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

No comments:

Post a Comment