While CtrlX works fine in vim under windows, CtrlA selects all (duh).
在windows下的vim中,ctrl + x可以很好地工作,而ctrl - la则选择all (duh)。
Is there a way to increment a number with a keystroke under windows?
是否有一种方法可以通过在窗口下的击键来增加数字?
7 个解决方案
#2
7
You can make CtrlA to increment in windows by opening up the 'mswin.vim' file in your vim directory and finding the section that looks like:
您可以通过打开“mswin”使ctrl加到窗口中。在您的vim目录中找到vim的文件,并找到如下部分:
" CTRL-A is Select all
noremap <C-A> gggH<C-O>G
inoremap <C-A> <C-O>gg<C-O>gH<C-O>G
cnoremap <C-A> <C-C>gggH<C-O>G
onoremap <C-A> <C-C>gggH<C-O>G
snoremap <C-A> <C-C>gggH<C-O>G
xnoremap <C-A> <C-C>ggVG
Comment out all of these lines as follows:
注释所有这些行如下:
" CTRL-A is Select all
"noremap <C-A> gggH<C-O>G
"inoremap <C-A> <C-O>gg<C-O>gH<C-O>G
"cnoremap <C-A> <C-C>gggH<C-O>G
"onoremap <C-A> <C-C>gggH<C-O>G
"snoremap <C-A> <C-C>gggH<C-O>G
"xnoremap <C-A> <C-C>ggVG
and the CtrlA keystroke will increment.
按下ctrl键将增加。
This is a pretty nice option when your keyboard doesn't have a real number pad.
这是一个很好的选择,当你的键盘没有真正的数字板。
#3
5
I realize that this is an old question, but I ran across another option today based on the following question. Making gvim act like it does on linux will allow CTRL-A to work as you expect it to:
我意识到这是一个老问题,但我今天在另一个问题上遇到了一个问题。使gvim在linux上的表现与它一样,将允许CTRL-A按您的期望工作:
how to make gvim on windows behave exacly like linux console vim?
如何让windows上的gvim表现得像linux控制台vim?
There is a section of the _vimrc that has the following items. These cause many of the control characters to act like they do on Windows.
_vimrc中有一个部分包含以下内容。这导致许多控制字符的行为就像它们在Windows上一样。
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
I commented out (with "
) the mswin lines and the set nocompatible
line. From there, I added set compatible
. This causes gvim to act like it does on linux. Thus, mine looks something like:
我注释掉了mswin行和set nocompatible行。从那里,我添加了set compatible。这导致gvim在linux上的行为与之类似。因此,我的看起来是这样的:
set compatible
source $VIMRUNTIME/vimrc_example.vim
"set nocompatible
"source $VIMRUNTIME/mswin.vim
"behave mswin
I just learned this trick today, so if I'm not completely correct in my information, please let me know.
我今天刚学过这个技巧,所以如果我的信息不完全正确,请告诉我。
#4
3
I modified TMealy's solution so that CtrlA still selects all (I find this useful), while CtrlI increments (also useful).
我修改了TMealy的解决方案,使ctrl拉仍然选择all(我发现这很有用),而ctrl +递增(也很有用)。
noremap <C-I> <C-A>
" CTRL-A is Select all
noremap <C-A> gggH<C-O>G
inoremap <C-A> <C-O>gg<C-O>gH<C-O>G
cnoremap <C-A> <C-C>gggH<C-O>G
onoremap <C-A> <C-C>gggH<C-O>G
snoremap <C-A> <C-C>gggH<C-O>G
xnoremap <C-A> <C-C>ggVG
#5
2
A similar problem occurs under GNU/Linux when using Vim with mswin.vim
. Remapping Alt+X to Ctrl+A prior to evoking mswin.vim
solved my issue.
在使用Vim和mswin.vim时,在GNU/Linux下也会出现类似的问题。在唤醒mswin之前,将Alt+X重新映射到Ctrl+A。vim解决我的问题。
execute "set <A-x>=\ex"
noremap <A-x> <C-A>
source $VIMRUNTIME/mswin.vim
behave mswin
Now, Alt+X and Ctrl+X respectively increase and decrease numbers in Vim.
现在,Alt+X和Ctrl+X分别增加和减少Vim中的数字。
Mapping to Alt key combinations is often not evident in Vim; read more about this here.
在Vim中,到Alt键组合的映射通常不明显;请在这里阅读更多。
#6
0
I am using cygwin terminal + screen, so <c-a> is captured by the terminal multiplexer. I used this mapping:
我正在使用cygwin终端+ screen,所以
:noremap <c-i> <c-a>
:noremap <我> < c - a >
#7
0
It seems that the CtrlA got mapped somewhere in startup. As suggested before, use:
似乎ctrl键在启动时被映射到某个地方。建议之前,使用:
unmap <c-x>
映射< cx >
I would use unmap, not nunmap.
我会用unmap,而不是nunmap。
#1
#2
7
You can make CtrlA to increment in windows by opening up the 'mswin.vim' file in your vim directory and finding the section that looks like:
您可以通过打开“mswin”使ctrl加到窗口中。在您的vim目录中找到vim的文件,并找到如下部分:
" CTRL-A is Select all
noremap <C-A> gggH<C-O>G
inoremap <C-A> <C-O>gg<C-O>gH<C-O>G
cnoremap <C-A> <C-C>gggH<C-O>G
onoremap <C-A> <C-C>gggH<C-O>G
snoremap <C-A> <C-C>gggH<C-O>G
xnoremap <C-A> <C-C>ggVG
Comment out all of these lines as follows:
注释所有这些行如下:
" CTRL-A is Select all
"noremap <C-A> gggH<C-O>G
"inoremap <C-A> <C-O>gg<C-O>gH<C-O>G
"cnoremap <C-A> <C-C>gggH<C-O>G
"onoremap <C-A> <C-C>gggH<C-O>G
"snoremap <C-A> <C-C>gggH<C-O>G
"xnoremap <C-A> <C-C>ggVG
and the CtrlA keystroke will increment.
按下ctrl键将增加。
This is a pretty nice option when your keyboard doesn't have a real number pad.
这是一个很好的选择,当你的键盘没有真正的数字板。
#3
5
I realize that this is an old question, but I ran across another option today based on the following question. Making gvim act like it does on linux will allow CTRL-A to work as you expect it to:
我意识到这是一个老问题,但我今天在另一个问题上遇到了一个问题。使gvim在linux上的表现与它一样,将允许CTRL-A按您的期望工作:
how to make gvim on windows behave exacly like linux console vim?
如何让windows上的gvim表现得像linux控制台vim?
There is a section of the _vimrc that has the following items. These cause many of the control characters to act like they do on Windows.
_vimrc中有一个部分包含以下内容。这导致许多控制字符的行为就像它们在Windows上一样。
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
I commented out (with "
) the mswin lines and the set nocompatible
line. From there, I added set compatible
. This causes gvim to act like it does on linux. Thus, mine looks something like:
我注释掉了mswin行和set nocompatible行。从那里,我添加了set compatible。这导致gvim在linux上的行为与之类似。因此,我的看起来是这样的:
set compatible
source $VIMRUNTIME/vimrc_example.vim
"set nocompatible
"source $VIMRUNTIME/mswin.vim
"behave mswin
I just learned this trick today, so if I'm not completely correct in my information, please let me know.
我今天刚学过这个技巧,所以如果我的信息不完全正确,请告诉我。
#4
3
I modified TMealy's solution so that CtrlA still selects all (I find this useful), while CtrlI increments (also useful).
我修改了TMealy的解决方案,使ctrl拉仍然选择all(我发现这很有用),而ctrl +递增(也很有用)。
noremap <C-I> <C-A>
" CTRL-A is Select all
noremap <C-A> gggH<C-O>G
inoremap <C-A> <C-O>gg<C-O>gH<C-O>G
cnoremap <C-A> <C-C>gggH<C-O>G
onoremap <C-A> <C-C>gggH<C-O>G
snoremap <C-A> <C-C>gggH<C-O>G
xnoremap <C-A> <C-C>ggVG
#5
2
A similar problem occurs under GNU/Linux when using Vim with mswin.vim
. Remapping Alt+X to Ctrl+A prior to evoking mswin.vim
solved my issue.
在使用Vim和mswin.vim时,在GNU/Linux下也会出现类似的问题。在唤醒mswin之前,将Alt+X重新映射到Ctrl+A。vim解决我的问题。
execute "set <A-x>=\ex"
noremap <A-x> <C-A>
source $VIMRUNTIME/mswin.vim
behave mswin
Now, Alt+X and Ctrl+X respectively increase and decrease numbers in Vim.
现在,Alt+X和Ctrl+X分别增加和减少Vim中的数字。
Mapping to Alt key combinations is often not evident in Vim; read more about this here.
在Vim中,到Alt键组合的映射通常不明显;请在这里阅读更多。
#6
0
I am using cygwin terminal + screen, so <c-a> is captured by the terminal multiplexer. I used this mapping:
我正在使用cygwin终端+ screen,所以
:noremap <c-i> <c-a>
:noremap <我> < c - a >
#7
0
It seems that the CtrlA got mapped somewhere in startup. As suggested before, use:
似乎ctrl键在启动时被映射到某个地方。建议之前,使用:
unmap <c-x>
映射< cx >
I would use unmap, not nunmap.
我会用unmap,而不是nunmap。