Auto-format with ReStructuredText does not handle headings correctly

7 views
Skip to first unread message

Simo Salminen

unread,
Dec 12, 2008, 4:53:46 AM12/12/08
to vim_use
Hi.

What would be The Way to have auto-formatting and still write headings
with ease?

I have following setup (macvim 7.2):
:set fo+=al
:set ft=rst

My problem is that when typing ReStructuredText headings, I have to
disable auto-formatting. Otherwise, text like this:

Heading
*********

Becomes:

Heading *********

Probably I have to do something with $VIMRUNTIME/indent/rst.vim, any
pointers how to proceed?

John Beckett

unread,
Dec 13, 2008, 9:52:49 PM12/13/08
to vim...@googlegroups.com
Simo Salminen wrote:
> My problem is that when typing ReStructuredText headings, I
> have to disable auto-formatting. Otherwise, text like this:
>
> Heading
> *********
>
> Becomes:
>
> Heading *********

Sorry, I don't know. However, you might be interested in the related:
http://vim.wikia.com/wiki/Underline_using_dashes_automatically

John

Simo Salminen

unread,
Dec 15, 2008, 9:15:30 AM12/15/08
to vim_use
I came up with bindings that disable the auto-format, and then enter
the heading markup chars. Got the bindings from:
http://blog.tuxcoder.com/2008/12/vim-restructure-text-macros.html


Here are the bindings:
noremap <C-u>1 :set fo-=a<Enter>yyPVr#yyjpo<esc>:set fo+=a<Enter>
inoremap <C-u>1 <esc>:set fo-=a<Enter>yyPVr#yyjpo<cr><esc>:set fo
+=a<Enter>i

noremap <C-u>2 :set fo-=a<Enter>yyPVr*yyjpo<esc>:set fo+=a<Enter>
inoremap <C-u>2 <esc>:set fo-=a<Enter>yyPVr*yyjpo<cr><esc>:set fo
+=a<Enter>i

noremap <C-u>3 :set fo-=a<Enter>yypVr=o<esc>:set fo+=a<Enter>
inoremap <C-u>3 <esc>:set fo-=a<Enter>yypVr=o<cr><esc>:set fo
+=a<Enter>i

noremap <C-u>4 :set fo-=a<Enter>yypVr-o<esc>:set fo+=a<Enter>
inoremap <C-u>4 <esc>:set fo-=a<Enter>yypVr-o<cr><esc>:set fo
+=a<Enter>i

noremap <C-u>5 :set fo-=a<Enter>yypVr^o<esc>:set fo+=a<Enter>
inoremap <C-u>5 <esc>:set fo-=a<Enter>yypVr^o<cr><esc>:set fo
+=a<Enter>i
Reply all
Reply to author
Forward
0 new messages