Mercurial > public > dotfiles
comparison vim/.vimrc @ 11:d428a965f322
Added a mapping/function to edit a file's other part (header/impl).
author | Brian Neal <bgneal1@rockwellcollins.com> |
---|---|
date | Mon, 04 Feb 2013 14:12:18 -0600 |
parents | b113527fa5d1 |
children | b8049010198a |
comparison
equal
deleted
inserted
replaced
10:b113527fa5d1 | 11:d428a965f322 |
---|---|
108 nnoremap ,nr :set relativenumber<CR> | 108 nnoremap ,nr :set relativenumber<CR> |
109 | 109 |
110 " Format paragraph | 110 " Format paragraph |
111 nnoremap ,p gqip | 111 nnoremap ,p gqip |
112 | 112 |
113 function BgnSwitchPart() | |
114 python << EOF | |
115 import vim, os.path, sys | |
116 fname = vim.current.buffer.name | |
117 base, ext = os.path.splitext(fname) | |
118 headers = ['.h', '.hxx'] | |
119 impls = ['.cpp', '.cxx', '.cc', '.c'] | |
120 new_exts = None | |
121 if ext in headers: | |
122 new_exts = impls | |
123 elif ext in impls: | |
124 new_exts = headers | |
125 | |
126 if new_exts: | |
127 for ext in new_exts: | |
128 new_fname = base + ext | |
129 if os.path.exists(new_fname): | |
130 vim.command(":e %s" % new_fname) | |
131 break | |
132 else: | |
133 sys.stderr.write("Could not find other part\n") | |
134 else: | |
135 sys.stderr.write("Uknown extension %s" % ext) | |
136 EOF | |
137 endfunction | |
138 | |
139 nnoremap ,s :call BgnSwitchPart()<CR> | |
140 | |
113 " Pathogen support | 141 " Pathogen support |
114 call pathogen#infect() | 142 call pathogen#infect() |