When I write a C code, I would like to wrap up after say 80 columns. Can
I do this in Vim? If yes, how? What are the related and useful commands
to wrap around while coding?
Regs,
Ajay.
Make sure 't' is in formatoptions to wrap code and not just comments:
:set fo+=t
and set textwidth to 80
:set tw=80
are the main two.
:help 'fo'
:help fo-table
:help 'tw'
You'll probably also want auto-indenting of some kind turned on.
:filetype indent on
may well suit you. If not, just
:set autoindent
:help :filetype-indent-on
:help 'ai'
The gq command is helpful for rewrapping stuff that's already written. I
tend to use linewise visual mode (shift-V) to highlight lines and then
type gq.
:help gq
:help v_q
Others may have more tips. There are so many...
Ben.
Hi,
:help wrap
eventually leads to 'textwidth', press <Ctrl>] to go to that help page.
so
:set textwidth=80
will set the maximum textwidth.
When you re-edit the already wrapped lines, visually select (press 'V')
the lines you want to reformat and hit gq (or just use gq$ to format
till the end of the line).
Regards,
Peter Palm
Mark the lines you want to wrap (with Shift-V or any other of the
v-commands), then type "!fmt<CR>"
-Erik
--
v4sw5RUYhw2ln3pr5ck0ma2u7Lw3+2Xm0l6/7Gi2e2t3b6AKMen5+7a16s0Sr1p-8.12/-6.56g6OR