[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]
Subject: DOCBOOK-APPS: Reformat DocBook paragraphs with Vim
Since monthes (years?) I was compelled tu use the following layout for my DocBook documents, in order to be able to reformat long paragraphs: <section> <title>Test Section</title> <para>This is a very long paragraph. This is a very long paragraph. This is a very long paragraph. This is a very long paragraph. This is a very long paragraph. This is a very long paragraph. This is a very long paragraph. This is a very long paragraph. This is a very long paragraph. This is a very long paragraph. This is a very long paragraph.</para> </section> Notice the blank lines around the paragraphs. With Vim, I used to type command gqap to reformat the paragraphs (ie wrap long lines if any). Today I wrote a small function for Vim that detects the current docbk syntax and reformats the paragraphs correctly even in situations like that (without blank lines): <section> <title>Test Section</title> <para>This is a very long paragraph. This is a very long paragraph. This is a very long paragraph. This is a very long paragraph. This is a very long paragraph. This is a very long paragraph. This is a very long paragraph. This is a very long paragraph. This is a very long paragraph. This is a very long paragraph. This is a very long paragraph.</para> </section> Here it is: imap <C-J> <C-O>:call ReformatParagraph()<cr> nmap <C-J> :call ReformatParagraph()<cr> vmap <C-J> gq<cr> function ReformatParagraph () if &filetype == 'docbk' exe "normal! ?<para>^Mv/<\/para>^Mgq" else normal gqap endif endfunction Note: ^M must be typed as true return characters using <C-V> Hope it helps! -- Jean-Baptiste Quenot http://caraldi.com/jbq/
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]
Powered by eList eXpress LLC