The default vim filetype commands create new bindings beginning with [ and ]. Is there a way to prevent them from doing so or control which bindings are created?
I like using [ and ] to scroll up and down by half pages, by analogy with { and } for paragraph navigation.
nnoremap ] <c-d>
vnoremap ] <c-d>
xnoremap ] <c-d>
nnoremap [ <c-u>
vnoremap [ <c-u>
xnoremap [ <c-u>
It works well for the text filetype, but programming language filetypes typically have bindings beginning with [ and ], for instance for Python files there are many structural navigation commands that I tend not to use:
...
n [M *@:call <SNR>25_Python_jump('n', '\v\S\n*(^(\s*\n*)*(class|def|async def)|^\S)', 'Wb', 0, v:count1)<CR>
n [m *@:call <SNR>25_Python_jump('n', '\v^\s*(class|def|async def)>', 'Wb', v:count1)<CR>
n [] *@:call <SNR>25_Python_jump('n', '\v\S.*\n+(def|class)', 'Wb', 0, v:count1)<CR>
n [[ *@:call <SNR>25_Python_jump('n', '\v^(class|def|async def)>', 'Wb', v:count1)<CR>
...
n ]M *@:call <SNR>25_Python_jump('n', '\v\S\n*(%$|^(\s*\n*)*(class|def|async def)|^\S)', 'W', 0, v:count1)<CR>
n ]m *@:call <SNR>25_Python_jump('n', '\v%$|^\s*(class|def|async def)>', 'W', v:count1)<CR>
n ][ *@:call <SNR>25_Python_jump('n', '\v%$|\S.*\n+(def|class)', 'W', 0, v:count1)<CR>
n ]] *@:call <SNR>25_Python_jump('n', '\v%$|^(class|def|async def)>', 'W', v:count1)<CR>
The file that defines this is located at
/usr/share/vim/vim81/ftplugin/python.vim
and does not appear to check the value of a "configuration variable" to determine whether it should bind keys.
Is there a creative way to overrule it?
[/]mappings. Some of them pretty use full (e.g.]pand[I). Have you thought about a different set of keys? Maybe<up>/<down>or just use<c-u>&<c-d>. Personally, I bind<d-j>&<d-k>, but that is MacVim specific – Peter Rincker Jan 07 '19 at 23:23