disable filetype-specific `[`/`]` bindings like `[[` and `[m`












1














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', 'vSn*(^(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', 'vS.*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', 'vSn*(%$|^(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?










share|improve this question






















  • There are quite a few [ / ] mappings. Some of them pretty use full (e.g. ]p and [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
    2 hours ago
















1














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', 'vSn*(^(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', 'vS.*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', 'vSn*(%$|^(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?










share|improve this question






















  • There are quite a few [ / ] mappings. Some of them pretty use full (e.g. ]p and [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
    2 hours ago














1












1








1







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', 'vSn*(^(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', 'vS.*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', 'vSn*(%$|^(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?










share|improve this question













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', 'vSn*(^(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', 'vS.*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', 'vSn*(%$|^(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?







key-bindings






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 5 hours ago









Gregory NisbetGregory Nisbet

699311




699311












  • There are quite a few [ / ] mappings. Some of them pretty use full (e.g. ]p and [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
    2 hours ago


















  • There are quite a few [ / ] mappings. Some of them pretty use full (e.g. ]p and [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
    2 hours ago
















There are quite a few [ / ] mappings. Some of them pretty use full (e.g. ]p and [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
2 hours ago




There are quite a few [ / ] mappings. Some of them pretty use full (e.g. ]p and [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
2 hours ago










1 Answer
1






active

oldest

votes


















3














You can unmap these within a file called ~/.vim/after/ftplugin/python.vim or $HOME/vimfiles/after/ftplugin/python.vim on windows, etc. containing:



silent! nunmap <buffer> ]]
silent! nunmap <buffer> [[
silent! nunmap <buffer> ][
silent! nunmap <buffer>
" and so on ...


vim executes scripts of the form after/ftplugin/{filetype}.vim after ftplugin/{filetype}.vim so you cna provide arbitrary overrides to the defaults.



Alternatively, you can use autocmds within your vimrc as follows:



function! PythonUnmaps()
silent! nunmap <buffer> ]]
silent! nunmap <buffer> [[
silent! nunmap <buffer> ][
silent! nunmap <buffer>
" and so on...
endfunction
augroup my_python_overrides
au!
autocmd FileType python call PythonUnmaps()
augroup END


Both of these approaches are general, you can replace python with whichever filetype you want to alter the settings for.






share|improve this answer























  • Is there a way to override it from within the .vimrc itself?
    – Gregory Nisbet
    3 hours ago










  • edited that into the answer
    – Mass
    3 hours ago











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "599"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fvi.stackexchange.com%2fquestions%2f18482%2fdisable-filetype-specific-bindings-like-and-m%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














You can unmap these within a file called ~/.vim/after/ftplugin/python.vim or $HOME/vimfiles/after/ftplugin/python.vim on windows, etc. containing:



silent! nunmap <buffer> ]]
silent! nunmap <buffer> [[
silent! nunmap <buffer> ][
silent! nunmap <buffer>
" and so on ...


vim executes scripts of the form after/ftplugin/{filetype}.vim after ftplugin/{filetype}.vim so you cna provide arbitrary overrides to the defaults.



Alternatively, you can use autocmds within your vimrc as follows:



function! PythonUnmaps()
silent! nunmap <buffer> ]]
silent! nunmap <buffer> [[
silent! nunmap <buffer> ][
silent! nunmap <buffer>
" and so on...
endfunction
augroup my_python_overrides
au!
autocmd FileType python call PythonUnmaps()
augroup END


Both of these approaches are general, you can replace python with whichever filetype you want to alter the settings for.






share|improve this answer























  • Is there a way to override it from within the .vimrc itself?
    – Gregory Nisbet
    3 hours ago










  • edited that into the answer
    – Mass
    3 hours ago
















3














You can unmap these within a file called ~/.vim/after/ftplugin/python.vim or $HOME/vimfiles/after/ftplugin/python.vim on windows, etc. containing:



silent! nunmap <buffer> ]]
silent! nunmap <buffer> [[
silent! nunmap <buffer> ][
silent! nunmap <buffer>
" and so on ...


vim executes scripts of the form after/ftplugin/{filetype}.vim after ftplugin/{filetype}.vim so you cna provide arbitrary overrides to the defaults.



Alternatively, you can use autocmds within your vimrc as follows:



function! PythonUnmaps()
silent! nunmap <buffer> ]]
silent! nunmap <buffer> [[
silent! nunmap <buffer> ][
silent! nunmap <buffer>
" and so on...
endfunction
augroup my_python_overrides
au!
autocmd FileType python call PythonUnmaps()
augroup END


Both of these approaches are general, you can replace python with whichever filetype you want to alter the settings for.






share|improve this answer























  • Is there a way to override it from within the .vimrc itself?
    – Gregory Nisbet
    3 hours ago










  • edited that into the answer
    – Mass
    3 hours ago














3












3








3






You can unmap these within a file called ~/.vim/after/ftplugin/python.vim or $HOME/vimfiles/after/ftplugin/python.vim on windows, etc. containing:



silent! nunmap <buffer> ]]
silent! nunmap <buffer> [[
silent! nunmap <buffer> ][
silent! nunmap <buffer>
" and so on ...


vim executes scripts of the form after/ftplugin/{filetype}.vim after ftplugin/{filetype}.vim so you cna provide arbitrary overrides to the defaults.



Alternatively, you can use autocmds within your vimrc as follows:



function! PythonUnmaps()
silent! nunmap <buffer> ]]
silent! nunmap <buffer> [[
silent! nunmap <buffer> ][
silent! nunmap <buffer>
" and so on...
endfunction
augroup my_python_overrides
au!
autocmd FileType python call PythonUnmaps()
augroup END


Both of these approaches are general, you can replace python with whichever filetype you want to alter the settings for.






share|improve this answer














You can unmap these within a file called ~/.vim/after/ftplugin/python.vim or $HOME/vimfiles/after/ftplugin/python.vim on windows, etc. containing:



silent! nunmap <buffer> ]]
silent! nunmap <buffer> [[
silent! nunmap <buffer> ][
silent! nunmap <buffer>
" and so on ...


vim executes scripts of the form after/ftplugin/{filetype}.vim after ftplugin/{filetype}.vim so you cna provide arbitrary overrides to the defaults.



Alternatively, you can use autocmds within your vimrc as follows:



function! PythonUnmaps()
silent! nunmap <buffer> ]]
silent! nunmap <buffer> [[
silent! nunmap <buffer> ][
silent! nunmap <buffer>
" and so on...
endfunction
augroup my_python_overrides
au!
autocmd FileType python call PythonUnmaps()
augroup END


Both of these approaches are general, you can replace python with whichever filetype you want to alter the settings for.







share|improve this answer














share|improve this answer



share|improve this answer








edited 3 hours ago

























answered 3 hours ago









MassMass

5,9551420




5,9551420












  • Is there a way to override it from within the .vimrc itself?
    – Gregory Nisbet
    3 hours ago










  • edited that into the answer
    – Mass
    3 hours ago


















  • Is there a way to override it from within the .vimrc itself?
    – Gregory Nisbet
    3 hours ago










  • edited that into the answer
    – Mass
    3 hours ago
















Is there a way to override it from within the .vimrc itself?
– Gregory Nisbet
3 hours ago




Is there a way to override it from within the .vimrc itself?
– Gregory Nisbet
3 hours ago












edited that into the answer
– Mass
3 hours ago




edited that into the answer
– Mass
3 hours ago


















draft saved

draft discarded




















































Thanks for contributing an answer to Vi and Vim Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fvi.stackexchange.com%2fquestions%2f18482%2fdisable-filetype-specific-bindings-like-and-m%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

CARDNET

Boot-repair Failure: Unable to locate package grub-common:i386

濃尾地震