如何使Neovim' s' e'地图额外的位置?
我试图用:nnoremap e mynewcommand
重新映射“ e”键,但是我对如何使当前的“结尾”完成一个额外的位置有些丢失。
例如,如果我有Word1 X Word2 Word3
(x是当前位置),它将在此处结束:Word1 WordX Word3
。
有没有办法重新映射它,以便它以Word + 1位置的结尾结束?像这样:Word1 Word2x Word3
谢谢!
Edit1:出于某些奇怪的原因,进行重新映射时::nnoremap< sl> e
,工作就像魅力 - 但是,:nnoremap< sj> b
不起作用。有人有任何想法吗?
EDIT2:按照要求,这是我的vim.init:
:nnoremap t r
:nnoremap <SPACE> <INSERT>
:vnoremap i <UP>
:vnoremap <SPACE> <INSERT>
:nnoremap i <UP>
:nnoremap k <DOWN>
:nnoremap j h
:nnoremap <S-l> e
:nnoremap <S-j> b
:nnoremap a <S-A>
:nnoremap vv <S-V>
:vnoremap k <DOWN>
:vnoremap j <LEFT>
:nnoremap dw daw
:inoremap jh <Esc>
" Settings.
set nocompatible
set showmatch
set ignorecase
set tabstop=4
set softtabstop=4
set expandtab
set shiftwidth=4
set autoindent
set number
set clipboard=unnamedplus
set ttyfast
" Vim-plug (Plugin Manager)
call plug#begin()
Plug 'itchyny/lightline.vim'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
call plug#end()
I am trying to remap 'e' keybind with :nnoremap e mynewcommand
, but I am a bit lost about how to make the current "end of word" finish one extra position.
For example, right now if I have word1 Xword2 word3
(X being the current position), it ends here: word1 wordX word3
.
Is there a way to remap it so that it ends on end of word + 1 position? Like this: word1 word2X word3
Thanks!
Edit1: For some weird reason, when doing the remap: :nnoremap <S-l> e
, works like a charm - but, the :nnoremap <S-j> b
doesn't work at. Does anyone have any idea?
Edit2: As requested, here is my vim.init:
:nnoremap t r
:nnoremap <SPACE> <INSERT>
:vnoremap i <UP>
:vnoremap <SPACE> <INSERT>
:nnoremap i <UP>
:nnoremap k <DOWN>
:nnoremap j h
:nnoremap <S-l> e
:nnoremap <S-j> b
:nnoremap a <S-A>
:nnoremap vv <S-V>
:vnoremap k <DOWN>
:vnoremap j <LEFT>
:nnoremap dw daw
:inoremap jh <Esc>
" Settings.
set nocompatible
set showmatch
set ignorecase
set tabstop=4
set softtabstop=4
set expandtab
set shiftwidth=4
set autoindent
set number
set clipboard=unnamedplus
set ttyfast
" Vim-plug (Plugin Manager)
call plug#begin()
Plug 'itchyny/lightline.vim'
Plug 'nvim-treesitter/nvim-treesitter', {'do': ':TSUpdate'}
call plug#end()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先:vim(和neovim)没有“地图”,因此您所做的不是“重新映射”,它们是“映射”(或“地图”,如果您真的想要)。
第二:正如某人已经指出的那样,
f&lt; space&gt;
已经满足了您的需求,因此您可能不应该为此花费太多精力。第三:
&lt; sl&gt;
和&lt; sj&gt;
是响应的,并且是不必要的方法来表达l
andj
。保持您的配置简单。第四:
:帮助j
和:帮助l
是两个非常有用的命令,因此您应该认真考虑覆盖的相对好处他们。特别是因为这样的事情。第五:
in
nnoremap&lt; key&gt; E
不是很可读,并且在匆忙格式化后可能会消失。您应该考虑这些替代符号:甚至可能是:
第六:您解释情况的方式不是很清楚:
2 2
在哪里?确切的光标是哪个角色?您能以更明确的方式重写它吗?类似:当前行为:
期望的行为:
第七:我可以,有点了解
nnoremap l e&lt; space&gt;
的渴望,因为希望光标在之后立即降落当前的单词似乎是一件合理的事情。您可能想放在那里,或插入括号或其他任何东西。但是我无法想象一个常见的场景足以证明nnoremap j b&lt; space&gt;
。什么,您到底想处理该映射?您要解决什么问题?而且,更重要的是,“不起作用”是什么意思?您是否试图通过在单词之前降落光标来映射
l
映射?由于&lt; space&gt;
将光标移至右侧,因此b&lt; space&gt;
显然无法使用,但是以下可能是:甚至可能:甚至可能:甚至可能:
First: Vim (and Neovim) doesn't have "maps" so what you are doing are not "remaps", they are "mappings" (or "maps", if you really want).
Second: as someone already pointed out,
f<Space>
already covers your need so you probably shouldn't spend so much energy on this.Third:
<S-l>
and<S-j>
are convoluted and unnecessary ways to sayL
andJ
. Keep your config simple.Fourth:
:help J
and:help L
are two very useful commands in their own right so you should think hard about the relative benefits of overriding them. Especially for something as trivial as this.Fifth: The
in
nnoremap <key> e
is not very readable and is likely to disappear after some hasty formatting. You should consider these alternatives notations:or maybe even:
Sixth: The way you explained your situation is not very clear:
Where did the
2
go? Which character was the cursor on, exactly? Could you rewrite it in a more explicit way? Something like:Current behaviour:
Desired behaviour:
Seventh: I can, sort of, understand the desire for
nnoremap L e<Space>
because wanting the cursor to land right after the current word seems like a reasonable thing to want. You may want to put something, there, or insert a bracket, or whatever. But I fail to imagine a scenario common enough to justifynnoremap J b<Space>
. What, exactly are you trying to do with that mapping? What problem are you trying to solve? And, more importantly, what does "doesn't work" mean?Are you trying to mirror your
L
mapping by landing the cursor before the word? Since<Space>
moves the cursor to the right, thenb<Space>
is obviously not going to work but the following might:or maybe even: