*** Vim *** Notes about my editor of choice. .. toctree:: django_completion .. highlight:: vim Sphinx ftplugin =============== I am very proud of my first vim plugin: :download:`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() endfun But if you want to pass parameters, you'll need something like this (please correct me if I'm wrong). .. literalinclude:: call_pyfunc_with_args.vim :language: vim :encoding: utf-8 Ugly Whitespace =============== To show all whitespace at line end:: :match Error /\s\+$/ To remove it:: :%s/\s\+$// Folding ======= 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): == ============================================== zf create folder zd delete folder under cursor zD delete folder recursive zE delete all folders in file zo open folder under curso zO open folder recursive zc close folder under cursor zC same as zc recursive za open folder if closed, close folder if opened == ============================================== .. _nion's blog: http://nion.modprobe.de/blog/archives/448-Folding-in-VIM.html 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" Beautiful. SnippetManager ============== https://github.com/SirVer/ultisnips :: :UltiSnipsEdit 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(n.n.`` does the first part of the substitution, but we are missing the closing brackets - record ``qq$a)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)n` - end recording `q` - and play `@q@@` - apply macro in register q `@q` - repeat last macro `@@` Registers ========= 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 :kbd:`Control-r a`. https://vi.stackexchange.com/a/15038 Links ===== - `Python and vim - Two great tastes that go great together `_