-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Do the <M-S-hjkl> mappings work natively on Mac? #18
Comments
Mapping meta does not work in the terminal because Vim cannot tell the difference between meta and esc. Neovim in the terminal works fine with meta maps (as well as |
Hi @gsavovski, I make Meta mappings work in my terminal by explicitly setting them on For example, if your terminal sends execute "set <M-a>=\<Esc>a" Therefore, to make " Timeout quickly on key codes to differentiate from normal <Esc>
set ttimeout ttimeoutlen=0
" Special named keys that cause problems when used literally
let namedkeys = { ' ': 'Space', '\': 'Bslash', '|': 'Bar', '<': 'lt' }
" Map Alt + ASCII printable chars
for n in range(0x20, 0x7e)
let char = nr2char(n)
let key = char
if has_key(namedkeys, char)
let char = namedkeys[char]
let key = '<' . char . '>'
endif
" Escaped Meta (i.e. not 8-bit mode)
" * Esc-[ is the CSI prefix (Control Sequence Introducer)
" * Esc-O is the SS3 prefix (Single Shift Select of G3 Character Set)
if char !=# '[' && char !=# 'O'
try
execute 'set <M-' . char . ">=\<Esc>" . key
catch
endtry
endif
endfor
unlet namedkeys n key char I've always meant to package this bit of vim voodoo into a plugin, but never Hence https://github.com/tpope/vim-sexp-mappings-for-regular-people :) EDIT (removed discussion of binding @justinmk just brought up a good point: this will cause set ttimeout ttimeoutlen=0 Setting In truth, none of this has personally never bothered me as I use Hope this helps! Thanks for the reminder @justinmk! |
Oops, forgot about that side effect. Appending my first post now... |
Okay, I've updated my comment with discussion of It's surely a hack, but a serviceable one nonetheless. |
One more thing I forgot to mention: Meta mappings work by default in vim if Most terminals can be configured to do this, but often do not do it by |
Hi @justinmk Thanks for the kind explanation. I actually remembered that I never could Hi @guns, Thanks for opening this new door :-) I already had set in my iTerm2 that the left option -=} cat So I tried explicitly setting: execute "set =^[J" The ASCII code for ‘^[‘ is ‘\094 \091’. Then I just put your code snippet in my vimrc and Few more questions bug me.. Why did the explicit setting I mention above didn’t work? Thanks again this is great :-) By the way the plugin already worked great in MacVim but |
Sounds like turning this off might enable meta-sets-top-bit mode, which is
The
Of course, we don't type Here is the relevant bit in vim: https://github.com/vim/vim/blob/60cce2f/src/ascii.h#L40-L41 #define Ctrl_chr(x) (TOUPPER_ASC(x) ^ 0x40) /* '?' -> DEL, '@' -> ^@, etc. */
#define Meta(x) ((x) | 0x80) Here we can also see why configuring your terminal to set the top bit when
I've edited my comment again to remove an errant debugging You've convinced me to start work on packaging this up as a plugin since it
It allows mapping Modifier + Arrow keys. I don't ever find myself touching the
Yes, the execute "map <special> \<Esc>\<C-g>… <4-…>"
execute "map! <special> \<Esc>\<C-g>… <4-…>" Now this map <4-s> :<C-u>update<CR> This is my favorite Vim hack, but it has the nasty side effect of borking Like I mentioned before, I use I suspect there is a way to abuse the termcap key code system to accomplish
Good to know. I compile vim with |
Thanks for the great plugin.
I'm trying hard to get it to work on a mac in iterm2 with vim version 7.4.488.
My .vimrc is pretty big so I'm eliminating any possible conflicts by using a plain vanila .vimrc
with nothing in it but your plugin.
None of the <M mappings work for me.
Am I missing some obvious thing specific to Mac. Anybody else has/had this issue?
I saw that there is a possibility to set your own mappings using the 'sexp-explicit-mappings' directive.
But I like the default mappings so want to stick to those..
Thanks
The text was updated successfully, but these errors were encountered: