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

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












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 Jan 8 at 8:59


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
    Jan 7 at 23:23















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 Jan 8 at 8:59


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
    Jan 7 at 23:23













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 Jan 8 at 3:08









Peter Mortensen

1646




1646










asked Jan 7 at 20:42









Gregory NisbetGregory Nisbet

711312




711312




marked as duplicate by Hotschke, Community Jan 8 at 8:59


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 Jan 8 at 8:59


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
    Jan 7 at 23:23












  • 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
    Jan 7 at 23:23







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
Jan 7 at 23:23





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
Jan 7 at 23:23










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
    Jan 7 at 21:48











  • edited that into the answer

    – Mass
    Jan 7 at 22:24


















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
      Jan 7 at 21:48











    • edited that into the answer

      – Mass
      Jan 7 at 22:24















    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
      Jan 7 at 21:48











    • edited that into the answer

      – Mass
      Jan 7 at 22:24













    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 Jan 7 at 22:21

























    answered Jan 7 at 21:46









    MassMass

    6,0651420




    6,0651420












    • Is there a way to override it from within the .vimrc itself?

      – Gregory Nisbet
      Jan 7 at 21:48











    • edited that into the answer

      – Mass
      Jan 7 at 22:24

















    • Is there a way to override it from within the .vimrc itself?

      – Gregory Nisbet
      Jan 7 at 21:48











    • edited that into the answer

      – Mass
      Jan 7 at 22:24
















    Is there a way to override it from within the .vimrc itself?

    – Gregory Nisbet
    Jan 7 at 21:48





    Is there a way to override it from within the .vimrc itself?

    – Gregory Nisbet
    Jan 7 at 21:48













    edited that into the answer

    – Mass
    Jan 7 at 22:24





    edited that into the answer

    – Mass
    Jan 7 at 22:24











    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 Jan 8 at 6:45









        Christian BrabandtChristian Brabandt

        15.5k2446




        15.5k2446












            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay