imap Alt Space (please help <:( )

248 views
Skip to first unread message

neolus

unread,
Jun 25, 2014, 9:29:38 AM6/25/14
to v...@vim.org
Hello, I simply wanted to redirect Alt + Space in insert mode to a plain
space
but this seems more complicated than I thought.

I've only tried i[nore]map <A-Space> <Space>
(or w/ imap <M-Space> <Space>)

but the same behaviour that it its always given me remains.
e.g. in insert I type Alt + Space & my input is grabbed untill I press one
more key
like say Alt + Space, F2 will print <80>

I really hope there's a way, and I hope somebody out there has an idea ?
I already searched alot for this but can't seem to find anyone else w/ the
same problem/need.
Thanks in advance if you're reading this !
Cheers !



--
View this message in context: http://vim.1045645.n5.nabble.com/imap-Alt-Space-please-help-tp5721993.html
Sent from the Vim - General mailing list archive at Nabble.com.

Bruno Sutic

unread,
Jun 25, 2014, 11:25:24 AM6/25/14
to vim...@googlegroups.com, v...@vim.org
Hey,
I've tried to make a plugin that consistently enables alt mappings in vim.
https://github.com/bruno-/vim-alt-mappings

It turns our that's a though problem for command line vim - mostly because enabling alt mappings breaks a lot of other stuff.

But anyway - can you post which vim are you using (command line, gui)?
Also, if it's terminal vim, then can you please post terminal (Terminal.all in OSX, iTerm, or something else)?

neolus

unread,
Jun 25, 2014, 3:04:43 PM6/25/14
to v...@vim.org
my bad, I'm using gvim 7.4.335-4




--
View this message in context: http://vim.1045645.n5.nabble.com/imap-Alt-Space-please-help-tp5721993p5721996.html

Michael Henry

unread,
Jun 25, 2014, 8:53:04 PM6/25/14
to vim...@googlegroups.com
> On Wednesday, June 25, 2014 3:29:38 PM UTC+2, neolus wrote:
>> Hello, I simply wanted to redirect Alt + Space in insert mode to a plain
>> space but this seems more complicated than I thought.

I see from a later post that you're running gvim. Normally that
makes mapping keys fairly straightforward, but mapping alt-space
seems to be an anomaly, at least for me running Gvim under KDE
on Linux. I usually have alt-space mapped for a system-wide
function, so I'd never tried mapping it in Gvim before. I get
the same behavior as you. A common way to determine which codes
are sent by pressing a key is to enter insert mode, press Ctrl-V
(or Ctrl-Q if you've got Ctrl-V mapped, which is sometimes done
on Microsoft Windows), then press the key in question. It
should insert its key code into the buffer for examination.
When I try this with alt-space, nothing happens until I press
another key. I think this means you may not have much success
trying to map alt-space in Gvim, at least without a more
thorough look into Gvim's guts to see what's going on under the
hood.

On 06/25/2014 11:25 AM, Bruno Sutic wrote:
> I've tried to make a plugin that consistently enables alt mappings in vim.
> https://github.com/bruno-/vim-alt-mappings

Hi, Bruno,

I took a quick look at your plugin page, and I see you've got it
marked "experimental" because of some unsolved issues. You
might like to take a look at my "fixkey" plugin to see how it
handles some of the issues you bring up:
https://github.com/drmikehenry/vim-fixkey

Michael Henry

John Little

unread,
Jun 26, 2014, 2:03:51 AM6/26/14
to vim...@googlegroups.com
Alt-whatever often belongs to the DE, and alt-space is used by windows and gnome at least; so, what OS? and desktop environment if linux?

Regards, John Little

Michael Henry

unread,
Jun 26, 2014, 7:49:58 AM6/26/14
to vim...@googlegroups.com
On 06/26/2014 02:03 AM, John Little wrote:
> Alt-whatever often belongs to the DE, and alt-space is used by
> windows and gnome at least; so, what OS? and desktop
> environment if linux?

In my case, I'm running Linux (Fedora 20) and KDE. While mostly
I configure KDE such that alt-space opens the window operations
menu (to match the equivalent behavior in Windows), I unmapped
this key for my Vim tests. In that environment, I can run gvim
and enter insert mode. When I press alt-space once, nothing
visible happens. Pressing alt-space again yields the following
character inserted into the buffer: Â

Using a unicode decoder, I see this is Unicode code point
U+00C2, "LATIN CAPITAL LETTER A WITH CIRCUMFLEX".

Testing in a terminal emulator (KDE Konsole), I run:

cat

then press alt-space. As with other alt keys in this terminal,
alt-space is encoded as an escape character followed by a space
(<Esc><Space> in Vim's notation). In console Vim, this is in
fact what I get when I enter insert mode and press alt-space.

Gvim is a different story, though. I don't really know how keys
are encoded and received by Gvim, other than to say that
pressing alt-space twice causes insertion of the "Â" character
on my system.

Since the original poster shows similar behavior (pressing
alt-space appears to do nothing, but following that keypress
with <F2> causes <80> to be inserted), I suspect alt-space isn't
mapped to anything outside of Gvim in his environment.

Michael Henry

Reply all
Reply to author
Forward
0 new messages