Skip to main content
Good point. We can still keep it a one-liner, though.
Source Link
B Layer
  • 20.1k
  • 2
  • 32
  • 59

You can either set 'textwidth' to 0 and then gq{movement} will line break at screen width or you can set it to desired width and disable autowrapping by changing 'formatoptions' (alias 'fo') like so...

set fo-=t
set fo-=c

Per :h fo-table:

With 't' and 'c' you can specify when Vim performs auto-wrapping:

value  action
""     no automatic formatting (you can use "gq" for manual formatting)
"t"    automatic formatting of text, but not comments
"c"    automatic formatting for comments, but not text (good for C code)

You can either set 'textwidth' to 0 and then gq{movement} will line break at screen width or you can set it to desired width and disable autowrapping by changing 'formatoptions' (alias 'fo') like so...

set fo-=t
set fo-=c

Per :h fo-table:

With 't' and 'c' you can specify when Vim performs auto-wrapping:

value  action
""     no automatic formatting (you can use "gq" for manual formatting)
"t"    automatic formatting of text, but not comments
"c"    automatic formatting for comments, but not text (good for C code)

You can either set 'textwidth' to 0 and then gq{movement} will line break at screen width or you can set it to desired width and disable autowrapping by changing 'formatoptions' (alias 'fo') like so...

set fo-=t fo-=c

Per :h fo-table:

With 't' and 'c' you can specify when Vim performs auto-wrapping:

value  action
""     no automatic formatting (you can use "gq" for manual formatting)
"t"    automatic formatting of text, but not comments
"c"    automatic formatting for comments, but not text (good for C code)
You need to remove flags one by one to get the correct behaviour if the options are in another order than 'tc': see :h set-=
Source Link

You can either set 'textwidth' to 0 and then gq{movement} will line break at screen width or you can set it to desired width and disable autowrapping by changing 'formatoptions' (alias 'fo') like so...

set fo-=tc=t
set fo-=c

Per :h fo-table:

With 't' and 'c' you can specify when Vim performs auto-wrapping:

value  action
""     no automatic formatting (you can use "gq" for manual formatting)
"t"    automatic formatting of text, but not comments
"c"    automatic formatting for comments, but not text (good for C code)

You can either set 'textwidth' to 0 and then gq{movement} will line break at screen width or you can set it to desired width and disable autowrapping by changing 'formatoptions' (alias 'fo') like so...

set fo-=tc

Per :h fo-table:

With 't' and 'c' you can specify when Vim performs auto-wrapping:

value  action
""     no automatic formatting (you can use "gq" for manual formatting)
"t"    automatic formatting of text, but not comments
"c"    automatic formatting for comments, but not text (good for C code)

You can either set 'textwidth' to 0 and then gq{movement} will line break at screen width or you can set it to desired width and disable autowrapping by changing 'formatoptions' (alias 'fo') like so...

set fo-=t
set fo-=c

Per :h fo-table:

With 't' and 'c' you can specify when Vim performs auto-wrapping:

value  action
""     no automatic formatting (you can use "gq" for manual formatting)
"t"    automatic formatting of text, but not comments
"c"    automatic formatting for comments, but not text (good for C code)
Source Link
B Layer
  • 20.1k
  • 2
  • 32
  • 59

You can either set 'textwidth' to 0 and then gq{movement} will line break at screen width or you can set it to desired width and disable autowrapping by changing 'formatoptions' (alias 'fo') like so...

set fo-=tc

Per :h fo-table:

With 't' and 'c' you can specify when Vim performs auto-wrapping:

value  action
""     no automatic formatting (you can use "gq" for manual formatting)
"t"    automatic formatting of text, but not comments
"c"    automatic formatting for comments, but not text (good for C code)