Disable filetype-specific `[`/`]` bindings like `[[` and `[m` [duplicate]












1















This question already has an answer here:




  • Unmapping filetype mappings

    1 answer




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















marked as duplicate by Hotschke, Community yesterday


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











  • 1




    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
    yesterday
















1















This question already has an answer here:




  • Unmapping filetype mappings

    1 answer




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















marked as duplicate by Hotschke, Community yesterday


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.











  • 1




    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
    yesterday














1












1








1








This question already has an answer here:




  • Unmapping filetype mappings

    1 answer




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
















This question already has an answer here:




  • Unmapping filetype mappings

    1 answer




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?





This question already has an answer here:




  • Unmapping filetype mappings

    1 answer








key-bindings






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday









Peter Mortensen

1646




1646










asked 2 days ago









Gregory NisbetGregory Nisbet

706312




706312




marked as duplicate by Hotschke, Community yesterday


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






marked as duplicate by Hotschke, Community yesterday


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.










  • 1




    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
    yesterday














  • 1




    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
    yesterday








1




1




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
yesterday




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
yesterday










2 Answers
2






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
    yesterday










  • edited that into the answer
    – Mass
    yesterday



















2














According to the help :h no_mail_maps and :h no_plugin_maps, it should be possible to prevent the creation of a filetype specific mapping by setting the variable:



:let g:no_<filetype>_maps = 1`


in your .vimrc, with <filetype> being replaced by python in your case. Unfortunately, the official python filetype plugin does not support this guard yet.



However, the upstream python Vim filetype repository does already support that as of commit db75a4614ffef770



So you could simply clone that plugin locally and use that, until the maintainer has sent update runtime files to Bram for inclusion with Vim (and Bram has committed it to the Vim repository).






share|improve this answer




























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    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
      yesterday










    • edited that into the answer
      – Mass
      yesterday
















    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
      yesterday










    • edited that into the answer
      – Mass
      yesterday














    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 yesterday

























    answered yesterday









    MassMass

    5,9951420




    5,9951420












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










    • edited that into the answer
      – Mass
      yesterday


















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










    • edited that into the answer
      – Mass
      yesterday
















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




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












    edited that into the answer
    – Mass
    yesterday




    edited that into the answer
    – Mass
    yesterday











    2














    According to the help :h no_mail_maps and :h no_plugin_maps, it should be possible to prevent the creation of a filetype specific mapping by setting the variable:



    :let g:no_<filetype>_maps = 1`


    in your .vimrc, with <filetype> being replaced by python in your case. Unfortunately, the official python filetype plugin does not support this guard yet.



    However, the upstream python Vim filetype repository does already support that as of commit db75a4614ffef770



    So you could simply clone that plugin locally and use that, until the maintainer has sent update runtime files to Bram for inclusion with Vim (and Bram has committed it to the Vim repository).






    share|improve this answer


























      2














      According to the help :h no_mail_maps and :h no_plugin_maps, it should be possible to prevent the creation of a filetype specific mapping by setting the variable:



      :let g:no_<filetype>_maps = 1`


      in your .vimrc, with <filetype> being replaced by python in your case. Unfortunately, the official python filetype plugin does not support this guard yet.



      However, the upstream python Vim filetype repository does already support that as of commit db75a4614ffef770



      So you could simply clone that plugin locally and use that, until the maintainer has sent update runtime files to Bram for inclusion with Vim (and Bram has committed it to the Vim repository).






      share|improve this answer
























        2












        2








        2






        According to the help :h no_mail_maps and :h no_plugin_maps, it should be possible to prevent the creation of a filetype specific mapping by setting the variable:



        :let g:no_<filetype>_maps = 1`


        in your .vimrc, with <filetype> being replaced by python in your case. Unfortunately, the official python filetype plugin does not support this guard yet.



        However, the upstream python Vim filetype repository does already support that as of commit db75a4614ffef770



        So you could simply clone that plugin locally and use that, until the maintainer has sent update runtime files to Bram for inclusion with Vim (and Bram has committed it to the Vim repository).






        share|improve this answer












        According to the help :h no_mail_maps and :h no_plugin_maps, it should be possible to prevent the creation of a filetype specific mapping by setting the variable:



        :let g:no_<filetype>_maps = 1`


        in your .vimrc, with <filetype> being replaced by python in your case. Unfortunately, the official python filetype plugin does not support this guard yet.



        However, the upstream python Vim filetype repository does already support that as of commit db75a4614ffef770



        So you could simply clone that plugin locally and use that, until the maintainer has sent update runtime files to Bram for inclusion with Vim (and Bram has committed it to the Vim repository).







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered yesterday









        Christian BrabandtChristian Brabandt

        15.5k2446




        15.5k2446















            Popular posts from this blog

            An IMO inspired problem

            Management

            Has there ever been an instance of an active nuclear power plant within or near a war zone?