Mercurial > public > dotfiles
changeset 13:0c225d280b06
Merge.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Tue, 04 Jun 2013 19:25:17 -0500 |
parents | 71f65ccb96f0 (current diff) d428a965f322 (diff) |
children | 357906c82c1f |
files | |
diffstat | 1 files changed, 28 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/vim/.vimrc Tue Jun 04 19:24:08 2013 -0500 +++ b/vim/.vimrc Tue Jun 04 19:25:17 2013 -0500 @@ -110,5 +110,33 @@ " Format paragraph nnoremap ,p gqip +function BgnSwitchPart() +python << EOF +import vim, os.path, sys +fname = vim.current.buffer.name +base, ext = os.path.splitext(fname) +headers = ['.h', '.hxx'] +impls = ['.cpp', '.cxx', '.cc', '.c'] +new_exts = None +if ext in headers: + new_exts = impls +elif ext in impls: + new_exts = headers + +if new_exts: + for ext in new_exts: + new_fname = base + ext + if os.path.exists(new_fname): + vim.command(":e %s" % new_fname) + break + else: + sys.stderr.write("Could not find other part\n") +else: + sys.stderr.write("Uknown extension %s" % ext) +EOF +endfunction + +nnoremap ,s :call BgnSwitchPart()<CR> + " Pathogen support call pathogen#infect()