disable filetype-specific `[`/`]` bindings like `[[` and `[m`
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
add a comment |
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
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
add a comment |
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
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
key-bindings
asked 5 hours ago
Gregory NisbetGregory Nisbet
701311
701311
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
add a comment |
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
add a comment |
1 Answer
1
active
oldest
votes
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.
Is there a way to override it from within the.vimrc
itself?
– Gregory Nisbet
4 hours ago
edited that into the answer
– Mass
3 hours ago
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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.
Is there a way to override it from within the.vimrc
itself?
– Gregory Nisbet
4 hours ago
edited that into the answer
– Mass
3 hours ago
add a comment |
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.
Is there a way to override it from within the.vimrc
itself?
– Gregory Nisbet
4 hours ago
edited that into the answer
– Mass
3 hours ago
add a comment |
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.
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.
edited 3 hours ago
answered 4 hours ago
MassMass
5,9701420
5,9701420
Is there a way to override it from within the.vimrc
itself?
– Gregory Nisbet
4 hours ago
edited that into the answer
– Mass
3 hours ago
add a comment |
Is there a way to override it from within the.vimrc
itself?
– Gregory Nisbet
4 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
4 hours ago
Is there a way to override it from within the
.vimrc
itself?– Gregory Nisbet
4 hours ago
edited that into the answer
– Mass
3 hours ago
edited that into the answer
– Mass
3 hours ago
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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