Hacker News new | past | comments | ask | show | jobs | submit login

How have you customized Vim to make it suitable for writing text that doesn't have a line break every 50 characters or so?



Primarily by having these in my .vimrc:

    autocmd FileType text set textwidth=75
    
    autocmd FileType text set formatoptions+=a

    autocmd FileType text set formatoptions+=w
explanation:

- formatoptions+=a: auto-format as you insert text, which means it will (basically) automatically insert a newline once you've typed 'textwidth' number of characters on your line. it will insert a newline while you are typing.

- formatoptions+=w: this isn't necessary, but it has an effect on the way the auto-formatting is done. i find the 'w' options more convenient. With 'w', a linebreak means a new paragraph, unless trailing whitespace at end of line. It means that the 'a' option doesn't auto join lines separated by a linebreak.

- if you're not familiar with Vim's autocmds, what they're doing in the above definitions is setting those options for any text files that are opened (and only text files).

I've also setup Taglist http://www.vim.org/scripts/script.php?script_id=273 so that it can show a listing of the markdown headings in my document.

[EDIT: added brief explanation of autocmds]


Thank you, that's useful to know if I ever try vim.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: