Thursday, June 27, 2013

Using Vim to replace line-terminal ReST :: with line-separate ReST :: indicators.

You can transform this ...

def foo(x, y):
   r'''Explanation of function::

      >>> foo(7, 8)
      ...

   Return something.
   '''
   ...

... to this ...

def foo(x, y):
   r'''Explanation of function:

   ::

      >>> foo(7, 8)
      ...

   Return something.
   '''
   ...

... using Vim substitution.

The command ...

   :%s/\(\s*\)\(.*\w\)\(::\)$/\1\2:\r\r\1::/g

... will do the trick.

No comments: