Notes about my editor of choice.

Sphinx ftplugin

I am very proud of my first vim plugin: sphinx.vim

For now, only creating and changing headings is mapped on the F1-F6 keys.

Wrapping a Python Function in a Vim function

Normally the following snippet would suffice:

fun! Vimfun()
    python pyfun()

But if you want to pass parameters, you’ll need something like this (please correct me if I’m wrong).

fun! Vimfun(x)
	python import vim
	python f(vim.eval(str('a:x')))

python << EOF
def f(x):
	print x

" run it
call Vimfun('Hello!')

Ugly Whitespace

To show all whitespace at line end:

:match Error /\s\+$/

To remove it:



See also: :help usr_28. Set folding for XML (in .vimrc):

" XML syntax folding
let g:xml_syntax_folding=1
au FileType xml setlocal foldmethod=syntax

Shortcuts (from nion’s blog on 2009-03-23):


create folder


delete folder under cursor


delete folder recursive


delete all folders in file


open folder under curso


open folder recursive


close folder under cursor


same as zc recursive


open folder if closed, close folder if opened

Write Buffer to Stdout

w !some_command

File Explorer

NERDTree is the answer. Wanted it on the right, so I added a one-liner to my .vimrc:

let g:NERDTreeWinPos="right"




Recording Macros

It’s so easy, that it it is useful for even three lines in the same document. Suppose you are editing the following README file:

# entry 1
some text here
# entry 2
more text here
# entry 3
more text here

You want to change the format from entry 1 to Entry(id=1). Here’s what I did:

  • navigate cursor to „entry“, then hit * (all highlighted, because of 'hlsearch'.)

  • cwEntry(<ESC>n.n. does the first part of the substitution, but we are missing the closing brackets

  • record qq$a)<ESC>nq
    • record q to register q (simple to type, also valid would be qx to record to register x)

    • go to end of line, append the bracket, go back to normal mode and jump to next occurence $a)<ESC>n

    • end recording q

  • and play @q@@
    • apply macro in register q @q

    • repeat last macro @@


To yank a word to register a type "ayw.

Show all registers with :reg and the register a with :reg a.

Paste register a in command mode (:) by hitting Control-r a.