I struggled with vim a bit tonight. I wanted to set it up to edit markdown files and have it behave like a word processor, where at a certain point on a line the text would automatically wrap. After googling for, well, hours, I found out that vim is not a word processor and word wrap simply isn't in its genes.
Well, kind of.
The first thing I did was install the markdown file type plugin. There are a few and I think I like this one the best: https://github.com/tpope/vim-markdown. Not sure why, it just seems to do the most stuff.
Then I set a few options in .vimrc, specific to markdown filetypes:
autocmd Filetype markdown setlocal wrap
autocmd Filetype markdown setlocal linebreak
autocmd Filetype markdown setlocal nolist
autocmd Filetype markdown setlocal columns=80
The columns=80 actually sets the width of the vim application to 80 columns, which sets he size of the terminal window to 80-columns on my Mac's iTerm. This is a bit annoying. What I really wanted was for vim to be wide, like the terminal, but for the text to wrap at 80 characters.
Alternatively, if I could live with line breaks, I could set up vim so hitting gq would force a paragraph to wordwrap, or gggqG to format the entire document. That config looks like this:
autocmd Filetype markdown setlocal tw=80
autocmd Filetype markdown setlocal wm=4
autocmd Filetype markdown setlocal fo=cat
But I can't live with line breaks. This markdown editing is what I do all of my writing in..., it's simple. I can strip it out if necessary, or I could go the other way and generate html, pdf's, etc. More on that in another post.
9 replies on “vim and markdown editing”
[…] stylesheet myself. I originally tried to use vim as my Markdown editor, but I found out that Vim sucks noodles at Markdown editing. I didn’t want to use a complex tool that has a lot of features. […]
I think what you were looking for is “set textwidth=0”. That actually adds newlines to your file where “wrap” just wraps it visually, but doesn’t enter any physical newlines.
oops, I meant “set textwidth=80” or however wide you want it to be. Setting it to 0 turns it off.
Isn’t that what autocmd Filetype markdown setlocal tw=80 does?
This content is very interesting but it took me a long time to find it in google.
I found it on 18 spot, you should focus on quality backlinks building, it will
help you to rank to google top 10. And i know how
to help you, just search in google – k2 seo tips and tricks
I see a lot of interesting posts on your blog. You have to
spend a lot of time writing, i know how to save you a lot of work, there is a tool that creates unique, google
friendly articles in couple of seconds, just search in google – laranita’s free content
I read a lot of interesting posts here. Probably you spend a lot of time writing, i know how to save you a lot of
work, there is an online tool that creates
unique, google friendly articles in seconds, just type in google
– laranitas free content source
Finally i quit my regular job, now i earn a lot of money on-line you
should try too, just search in google – slabs roulette system
I like the valuable information you provide in your articles.
I’ll bookmark your blog and check again here frequently.
I am quite certain I will learn many new stuff right here!
Good luck for the next!
my web blog – [cheap personalized decor in your home at parisloftgifts free personalization](http://translate.google.cn/ “cheap personalized decor in your home at parisloftgifts free personalization”)