Matthew Gilbert wrote:
A.J.Mechelynck wrote:
Matthew Gilbert wrote:
Gene Kwiecinski wrote:
I'm using GVIM on WinXP SP2:
I'm trying to map ALT-ENTER. It doesn't work (I just get enter).
Uhhh, ain't alt-enter trapped by the OS, ie, to switch between
window/console modes?
I'm using GVIM. Also, I can enter CTRL-V_ALT-ENTER and <M-CR> is
inserted at the command line without issue. Thanks though. _matt
This at least means that gvim is getting the alt-enter keystroke all
right.
Can you use at least one of
:inoremap <M-CR> Meta-Carriage-Return
or
:inoremap <A-Enter> Alt-Enter
after starting Vim with
gvim -u NONE -N
? If you can, then there is something that overrides it when you use
your usual vimrc and plugins.
Nope. I still get the regular enter behavior (inserts a newline). Thanks
_matt
I also am unable to successfully map <M-CR>. Throughout, I'm using
Tony's suggested clean-startup of Vim:
gvim -u NONE -N
On Windows using gvim 7.0, I get the same behavior described by the
original poster. M-CR comes through in insert mode as plain CR. In
fact, I get plain CR on Windows for insert-, command-line-, and
normal-mode mappings like this:
:inoremap <M-CR> Insert-Meta-CR
:cnoremap <M-CR> Command-line-Meta-CR
:nnoremap <M-CR> Normal-Meta-CR
As with the O.P., I'm able to press CTRL-V M-CR on the command-line and
Vim will insert <M-CR>.
As another oddity, after this mapping:
:inoremap <M-CR> Insert-Meta-CR
I get the following back from the :imap command:
i {black square} * Insert-Meta-CR
where {black square} is a single-character-wide solid black square. It
makes me think that Vim didn't translate the six characters <M-CR>
properly in the initial :inoremap <M-CR> invocation. That would go
along with the fact that pressing CTRL-V M-CR on the command line does
properly convert the M-CR keystroke into the output <M-CR>.
On Ubuntu Linux using vim 7.0.206, starting clean and without any
mappings at all, if I press <M-CR> in insert mode it appears at first
that nothing happens, but whichever key I press next causes a capital-A
with a circumflex to appear. If I execute the following command:
:inoremap <M-CR> Insert-Meta-CR
Nothing seems to change in insert mode (I still get A-with-circumflex on
the keystroke after pressing <M-CR>). When I look at the mappings with
:imap, I get this:
i {box with "00 0D" and blank} * Insert-Meta-CR
where the curly-braced description represents the outline of a
rectangular box in which are the numbers "00" above "0D", followed by a
blank area still inside the outline.
On Ubuntu Linux, if I press CTRL-V M-CR in command-line-mode, I get
nothing until the next keypress, at which time A-with-circumflex is
inserted.
On the mac using gvim 7.0.206, the keyboard is a little different. Macs
have both an "Alt" key (named "Option") and a "Command" key. Both of
these modifier keys are used in native Mac applications. "Command" is
physically in the same position on a Mac keyboard as "Alt" is on a PC
keyboard; therefore, it's sometimes preferable to map a given function
to "Alt" + Key on a PC and to "Command" + Key on a Mac. The letter "D"
is used in mappings to mean the "Command" modifier. Starting gvim clean
and in insert mode, when I press either Option-CR or Command-CR I appear
to get plain old CR. When I execute the following:
:inoremap <M-CR> Insert-Meta-CR
the key Option-CR still does a plain CR. The :imap command shows the
correct-looking mapping:
i <M-CR> * Insert-Meta-CR
When I try to map Command-CR as follows:
:inoremap <D-CR> Insert-Command-CR
it works properly. Pressing Command-CR in insert mode actually inserts
the string "Insert-Command-CR". Issuing :imap shows the proper mapping
as well:
i <D-CR> * Insert-Command-CR
If I press CTRL-V M-CR on the command-line, I get ^M back (CTRL-M, which
is plain CR). If I press CTRL-V Command-CR, I get <D-CR>.
So on the Mac, it looks like meta-key mapping of CR doesn't work, but
command-key mapping does.
On all three platforms, using A-Enter instead of M-CR seems to make no
discernible difference.
Hopefully this multi-platform test information helps track down the problem.
Thanks,
Michael Henry