|
Hello all.
I am trying to do some keymappings to keys combinations which uses the Alt key. My problem is that, except for Alt-[Left|right|Up|Down] combination, any other combination I try like, Alt-= (M-=), Alt-t(M-t), etc ... Seems to be recognized as utf characters, so for instance <C-M-w> is recognized as <97> when I check my keymaps using the :map command. Similar thing happens to <M-t> which is recognized as an O with a hat symbol on it. So seems my Alt combination are mapped to utf characters rather than the real keyboard keys. I have been looking into google and seems vim always translates this combination of Alt keys to UTF characters. I understand that this is done while in insert mode, but why the map nmap command precessed <M-t> as an UTF character when I put something like: nmap <silent> <M-t> <C-W>v In my .vimrc? Is there any reliable method to use Alt keymaps that works in both vim and gvim and for Linux and Mac? Thanks. -- Un saludo Best Regards Pablo Giménez -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php |
|
On Sunday, August 19, 2012 6:35:03 PM UTC-5, [hidden email] wrote:
> Hello all. > I am trying to do some keymappings to keys combinations which uses the Alt key. > My problem is that, except for Alt-[Left|right|Up|Down] combination, any other combination I try like, Alt-= (M-=), > Alt-t(M-t), etc ... > > Seems to be recognized as utf characters, so for instance <C-M-w> is recognized as <97> when I check my keymaps using the :map command. > Similar thing happens to <M-t> which is recognized as an O with a hat symbol on it. > > So seems my Alt combination are mapped to utf characters rather than the real keyboard keys. > I have been looking into google and seems vim always translates this combination of Alt keys to UTF characters. > I understand that this is done while in insert mode, but why the map nmap command precessed <M-t> as an UTF character when I put something like: > > nmap <silent> <M-t> <C-W>v > In my .vimrc? > Is there any reliable method to use Alt keymaps that works in both vim and gvim and for Linux and Mac? > Even though Vim sees the keys as a Unicode character, pressing the keys should still execute the mapping. I don't think Vim can reliably do CTRL+Alt mappings, but I believe Alt-{key} mappings normally work fine. Where do you encounter problems? Is it just terminal Vim, or also gvim? What happens when you press your ALT-t mapping? What did you expect to happen instead? What information led you to think it wouldn't work? -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php |
|
In reply to this post by Pablo Giménez Pizarro
On Sun, Aug 19, 2012 at 07:35:03PM EDT, Pablo Giménez wrote:
> I am trying to do some keymappings to keys combinations which uses the > Alt key. [..] What terminal(s) are you using..? CJ -- Oh My God!!! Larry is back! -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php |
|
In reply to this post by Ben Fritz
On 21.08.12 08:19, Ben Fritz wrote:
> Even though Vim sees the keys as a Unicode character, pressing the > keys should still execute the mapping. > > I don't think Vim can reliably do CTRL+Alt mappings, but I believe > Alt-{key} mappings normally work fine. Mostly. Over here, with: VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Apr 18 2012 19:32:03) Included patches: 1-496 these Alt mappings work for me in more cases than not: " Putting åæø and «» on Alt, is handier than digraphs: inoremap <expr> <A-a> "\uE5" inoremap <expr> <A-e> "\uE6" inoremap <expr> <A-o> "\uF8" inoremap <expr> <A-<> "\uAB" inoremap <expr> <A->> "\uBB" They work fine in insert mode, and for single character replacement, using "cl", but fail when using "r". e.g. Applying "cl<A-a>" to "x" gives å, which is correct. Applying "r<A-a>" to "x" gives á, which is wrong. Maybe that has been fixed since patch 496. I've just learnt to use "cl" instead of "r" - it's more flexible, anyway. Erik -- "The Southern Ocean occupies about 22 per cent of the area of the total ocean, and yet it absorbs about 40 per cent of the carbon dioxide that's stored by the ocean and about half the heat that's stored by the ocean," climate scientist Steve Rintoul says. - http://abc.com.au/news/2011-11-29/southern-ocean-waters-warming/3700532 -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php |
|
On Wednesday, August 22, 2012 3:45:58 AM UTC-5, Erik Christiansen wrote:
> On 21.08.12 08:19, Ben Fritz wrote: > > > Even though Vim sees the keys as a Unicode character, pressing the > > > keys should still execute the mapping. > > > > > > I don't think Vim can reliably do CTRL+Alt mappings, but I believe > > > Alt-{key} mappings normally work fine. > > > > Mostly. Over here, with: > > > > VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Apr 18 2012 19:32:03) > > Included patches: 1-496 > > > > these Alt mappings work for me in more cases than not: > > > > " Putting åæø and «» on Alt, is handier than digraphs: > > inoremap <expr> <A-a> "\uE5" > > inoremap <expr> <A-e> "\uE6" > > inoremap <expr> <A-o> "\uF8" > > inoremap <expr> <A-<> "\uAB" > > inoremap <expr> <A->> "\uBB" > > > > They work fine in insert mode, and for single character replacement, > > using "cl", but fail when using "r". e.g. > > > > Applying "cl<A-a>" to "x" gives å, which is correct. > > Applying "r<A-a>" to "x" gives á, which is wrong. > This is very strange, and I can duplicate it in 7.3.622. I think the problem is that single-letter replacement with 'r' does not put you into insert mode, it's just a command that takes a letter, similar to f, F, t, and T. I did not realize this, and probably would not have realized it, but then while searching for the behavior we're seeing, I stumbled on :help language-mapping, which notes that language maps apply to (among other things) 'the argument of the commands that accept a text character, such as "r" and "f"'. Further, I note that while :help R says it will "enter Replace mode", :help r just says it will "replace the character under the cursor with {char}". So it looks like r doesn't really put you in any particular mode, it's just an incompletely typed command. -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php |
|
On Wednesday, August 22, 2012 9:10:41 AM UTC-5, Ben Fritz wrote:
> Further, I note that while :help R says it will "enter Replace mode", :help r just says it will "replace the character under the cursor with {char}". So it looks like r doesn't really put you in any particular mode, it's just an incompletely typed command. I meant to also note, replace mode with R DOES work with the given mappings. -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php |
|
In reply to this post by Erik Christiansen
2012/8/22 Erik Christiansen <[hidden email]>
Thanks all for your answers.
I am using Vim with terminals Mrxvt in Linux and iTerm2 in the Mac. I have the same problem in Gvim as well.
As you can see in my first post I a mtryin to map <M-t> to <C-W>v, So Alt+t will make a vertical split. But looking at your mapping examples seems I am doing the map wrong. Probably is because Vim sends the unicode keymao rather than the keymap I expect. What would be way to, let's say make my Alt-t keymap: nmap <M-t> <C-W>v But using unicode? Thanks
-- Un saludo Best Regards Pablo Giménez -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php |
|
On Wed, Aug 22, 2012 at 10:28:47AM EDT, Pablo Giménez wrote:
> I am using Vim with terminals Mrxvt in Linux and iTerm2 in the Mac. > I have the same problem in Gvim as well. [..] Don't have access to either.. What happens if you use <Esc> instead of <M- or <A- i.e. map <Esc>a :echo 'You hit Alt+A'<CR> CJ -- Mooo Canada!!!! -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php |
|
In reply to this post by Pablo Giménez Pizarro
On Wednesday, August 22, 2012 9:28:47 AM UTC-5, [hidden email] wrote:
> > As you can see in my first post I a mtryin to map <M-t> to <C-W>v, > So Alt+t will make a vertical split. > But looking at your mapping examples seems I am doing the map wrong. > Why do our examples indicate you're doing it wrong? > Probably is because Vim sends the unicode keymao rather than the keymap I expect. > What would be way to, let's say make my Alt-t keymap: > nmap <M-t> <C-W>v Looks like it should work to me. In fact, entering exactly that command into my gvim allows me to press ALT+t to open a new vertical split window, just as intended. What happens if you open gvim with gvim -N -u NONE -i NONE and then execute your map command? Does it work then? > But using unicode? You should need absolutely zero knowledge of how Vim internally represents an ALT+t keystroke, nor how the keyboard sends it, in order to map it in gvim. You can try using <Esc> as Chris suggests, but this should only work in some terminals, and it's a hack, not the "correct" solution. It WON'T work in gvim. I don't use the terminal enough to know off-hand what that "correct" solution is, but I'd get it working in gvim first and then figure out why it's not working in your terminal. See :help :map-alt-keys, which says (among many other things) that using the Alt keys in gvim "should always work". -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php |
|
On Wed, Aug 22, 2012 at 12:43:48PM EDT, Ben Fritz wrote:
> On Wednesday, August 22, 2012 9:28:47 AM UTC-5, [hidden email] wrote: [..] > You can try using <Esc> as Chris suggests, but this should only work > in some terminals, and it's a hack, not the "correct" solution. It > WON'T work in gvim. I don't use the terminal enough to know off-hand > what that "correct" solution is, but I'd get it working in gvim first > and then figure out why it's not working in your terminal. See :help > :map-alt-keys, which says (among many other things) that using the Alt > keys in gvim "should always work". Not a "hack", much less a "solution". More of a (very informal) diagnostic tool.. I noticed that the OP's last name has an accented ’é’ in it.. so I'm wondering what kind of ‘keyboard’ (physical/logical) he's using.. what his Alt keys actually do... you know.. thinking AltGr.. eightBitInput.. and such.. I know.. not really a diagnostic tool either.. hunch perhaps..? :-) CJ -- Alex Perez is aliveeeeeeee!!! -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php |
|
In reply to this post by Ben Fritz
2012/8/22 Ben Fritz <[hidden email]>
It works in gvim, but not in the terminal. I havetried gnome-terminal, mrxvt and xterm In all of them when I press Alt-t with the previous mapping nothing happens. I have tried to map the vertical split keymap to Alt-u, then I got a message saying that the buffer is Already at the oldest change. So for the terminal seems that Alt-u is the same as pressing just u.
-- Un saludo Best Regards Pablo Giménez -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php |
|
In reply to this post by Chris Jones-44
2012/8/22 Chris Jones <[hidden email]>
Wow this seems to work! Why <Esc> is working? Thanks
-- Un saludo Best Regards Pablo Giménez -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php |
|
On Wednesday, August 22, 2012 2:50:35 PM UTC-5, [hidden email] wrote:
> 2012/8/22 Chris Jones <[hidden email]> > > > On Wed, Aug 22, 2012 at 10:28:47AM EDT, Pablo Giménez wrote: > > > > > I am using Vim with terminals Mrxvt in Linux and iTerm2 in the Mac. > > > I have the same problem in Gvim as well. > > > > [..] > > > > Don't have access to either.. > > > > What happens if you use <Esc> instead of <M- or <A- > > > > i.e. > > > > map <Esc>a :echo 'You hit Alt+A'<CR> > > Wow this seems to work! > Why <Esc> is working? Some terminals send ALT+t to Vim as an <Esc> character ^[ followed by t. So mapping <Esc>t in these terminals will react to what the terminal sends for ALT+t, but will not be able to tell the difference between this an you actually pressing <Esc> followed by t. I think it's possible to correct the problem in your terminal config, but I don't know much about that. Try these two tips: http://vim.wikia.com/wiki/Fix_meta-keys_that_break_out_of_Insert_mode http://vim.wikia.com/wiki/Get_Alt_key_to_work_in_terminal And remember that <Esc>t probably won't work in gvim, although ALT+t works out-of-the-box. -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php |
|
2012/8/22 Ben Fritz <[hidden email]> On Wednesday, August 22, 2012 2:50:35 PM UTC-5, [hidden email] wrote: Ok thanks I'll take a look.
No problem I have different settigns for gvim and vim.
-- Un saludo Best Regards Pablo Giménez -- You received this message from the "vim_use" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php |
| Powered by Nabble | Edit this page |
