Question

My keyboard's layout(2nd row):

`1...0-=Backspace

I want to map function calls to Ctrl+ 0, -, =.

This is the function I created:

" it doesn't work
nnoremap <C-=>  :call IncFontSize(+1)<CR>

" it works
nnoremap <C-->  :call IncFontSize(-1)<CR>

" it doesn't work
nnoremap <C-0>  :call IncFontSize(0)<CR>

fun! IncFontSize(inc)
    if !exists('+guifont')
        return
    endif
    let s:defaultfont = 'Ubuntu Mono 12'
    if a:inc==0 || empty(&guifont)
        let &guifont = s:defaultfont
        return
    endif
    let &guifont = substitute(&guifont, '\d\+$', '\=submatch(0)+'.a:inc, '')
endfun

How can I map function calls to these keys?

Was it helpful?

Solution

Notice how in command-line mode, Ctrl-_ results in ^_, but Ctrl-0 and Ctrl-= yield nothing.

Due to the way that the keyboard input is handled internally, differentiating this as well as many other key combinations (like Ctrl+Letter vs. Ctrl+Shift+Letter) unfortunately isn't possible today, even in GVIM. This is a known pain point, and the subject of various discussions on vim_dev and the #vim IRC channel.

Some people (foremost Paul LeoNerd Evans) want to fix that (even for console Vim in terminals that support this), and have floated various proposals, cp. link

But as of today, no patches or volunteers have yet come forward, though many have expressed a desire to have this in a future Vim 8 major release.

OTHER TIPS

http://vim.wikia.com/wiki/Fast_window_resizing_with_plus/minus_keys

just only + and - …… no alias name

:nmap + :echo "hello world"<CR>

Is it what you want ?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top