I have shortcuts to edit my
vimrc and to source my
vimrc. When I'm writing code I can quickly add a new mapping and then source
vimrc. And all that would be good if I did not use
autocmd FileType for most of my mappings.
Since most mappings are specific to one file type I keep my
vimrc in a form similar to this:
function! FtPython() setlocal expandtab shiftwidth=4 softtabstop=4 autoindent nnoremap <buffer> <localleader>c I#<esc> " Let's say that this is a new mapping nnoremap <buffer> <localleader>cc ^wC:<esc><left>i endfunction if has("autocmd") augroup filetype_vimrc autocmd! autocmd FileType python call FtPython() ... endif
Yet, when I add a new mapping to
FtPython() and source my
vimrc, the new mapping is not present in the
python buffers because the
FileType event happened long ago, when the file was read.
When I read a buffer back into a window
FileType will be fired and the mapping will be added, but that does not happen when a window is already open and I just move into it (Ctrl+W). In essence, once I add a new mapping all currently open windows need to be "kicked" to get the new mapping.
I work around it by doing (I force the
FileType event to fire):
But that is quite a lot of typing, sometimes I have 2-3
python files in different windows (
split/vsplit) and I need to do it for each.
argdo is not an option since it will close the windows (as far as I know).
Is there a good way to fire the
FileType event on all windows that Vim is currently showing?
Or, maybe, is there a better way to structure the mappings?