# HG changeset patch # User Brian Neal # Date 1370391917 18000 # Node ID 0c225d280b0601659972fa4ec81d771ec3d57d00 # Parent 71f65ccb96f036c9879fbd07153696818293526a# Parent d428a965f32201ce984f1b4e9eb4f085b5915825 Merge. diff -r 71f65ccb96f0 -r 0c225d280b06 vim/.vimrc --- 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() + " Pathogen support call pathogen#infect()