简体   繁体   中英

How can I use the + (or =) key in a mapping in vim?

I wanted to remap (for normal mode) Ctrl + a to Ctrl + = and Ctrl + x to Ctrl + - but it didn't work.

Is there another way to write this?

I had a problem using and because my shell uses those to resize my window and font size. I was able to map '+' and '-' to the commands so pressing them in normal mode incremented and decremented values.

map + <C-a>
map - <C-x>

Is that what you were trying to accomplish? I don't know if that will work for you, since they probably have different uses that I don't use.

You could also use a mapleader instead of control to do this and not mess with any default uses:

let mapleader=","
map <Leader>+ <C-a>
map <Leader>- <C-x>

Instead of C-+ and C-- , you would use ,+ and ,- .

我不确定Ctrl + = ,但对于Ctrl + - ,请尝试使用Ctrl + _ (用下划线替换连字符)。

Works for me.

map <C-a> <C-=>
map <C-=> :echo 'ken'<CR>

map <C-x> <C-->
map <C--> :echo 'barbie'<CR>

Then <Ca> should echo ken and <C--> should echo barbie

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM