Santhalus wrote:
> Do you use some automata for the <pre>-wrapping and code
> indenting or do it manually?
> Tip: When doing code formatting manually I found it often
> more convenient to copy/paste the content from the original
> vim tip than modify the code in the imported version - this
> way you can preserve the original indentation easily.

Did you see the amazing code from Ipkiss?

He has an automated method for doing what you suggest above.

http://vim.wikia.com/wiki/User:Ipkiss/Using_vim_to_edit_tips

http://vim.wikia.com/wiki/User:Ipkiss/Restoring_part_of_an_original_tip

However, I confess that I haven't yet used the above because
I've been in a scripting frenzy (while learning Python and
Pywikipedia). I haven't spent much time indenting code, so I
haven't implemented an automated procedure (although I have
downloaded everything and admired it).

While bulk editing, I mostly work in a trance, and I can't give
much attention to fixing code, although I have done a bit.

I've only done this in the last few days, using:

nnoremap \0 :bufdo %s/\s\+$//e<CR> <bar> %s/&#35;/#/ge<CR>
nnoremap \1 :bufdo %s/^== \| ==$/==/gce<CR>
nnoremap \2 :bufdo %s#<\(/\{0,1\}\)code>#<\1tt>#gce<CR>
nnoremap ,, o<pre><Esc>}
nnoremap ,< O</pre><Esc>0

\0 trims trailing spaces and converts '&#35;' to '#'.

\1 converts stuff like '== Comments ==' to '==Comments=='
(sorry, but since I'm doing this, I thought I would indulge my
preferences!).

\2 converts <code>..</code> to <tt>..</tt> (I like consistency,
and I think most of use (all?) currently use <tt>).

I find it easy to type the ',,' and ',<' stuff, which insert the
<pre> tags. I might need to press '}' a few times after ',,'.

Suggestions on the above are welcome.

John

_______________________________________________
Vim-l mailing list
Vim-l@wikia.com
http://lists.wikia.com/mailman/listinfo/vim-l

Reply via email to