Thursday, February 9, 2012

Re: vim-orgmode

On Tue, 7 Feb 2012, Chris Jones wrote:

> On Mon, Feb 06, 2012 at 01:40:33PM EST, Jan Christoph Ebersbach wrote:
>> Hi Stephan,
>>
>>> The other course of action would be to complain to the
>>> orgmode-author that his mappings are not compatible with all vim
>>> versions. Also, mappings that use the shift and control key a lot
>>> are really not something you should use in vim. Actually it reminds
>>> me more of this... other... editor.
>>
>> It's true, <S-CR> can not be used in the command-line version of vim.
>> I haven't found a good replacement for it, yet. If you need to use
>> vim on the command-line I recommend mapping the functionality to
>> another key.
>
> In X11, a simple workaround (regardless of the terminal emulator) is
> to map <Shift+Enter> to a character that is not bound to a Vim command
> by default, via xmodmap:
>
> | $ xmodmap -e "keysym Return = Return currency"¹
>
> You can check at the bash prompt that hitting <Shift+Enter> now
> generates '¤', not '
> '.

In general, you should map the keys at the level where they're
problematic. So, `xmodmap` is too heavy-handed, since mapping
Shift+Enter at that level breaks Shift+Enter for things that can already
handle it (e.g. GVim and many other X11 programs).

Using XTerm's modifyOtherKeys mode (which isn't supported by most
programs, but allows the detection of virtually all keycodes), <Shift> +
<Enter> is detected as:

\e[27;2;13~

I'm pretty sure the '27' means it's an extended keycode. The '2' means
it's modified by shift. The 13 is newline. So, you can tell your
terminal emulator to send that code for <S-CR>. (The only reason to
pick this code is that, in the future, if other terminals adopt this
convention, the mapping shouldn't hurt anything.)


For uxterm, I would add the following to ~/.Xdefaults or ~/.Xresources:

UXTerm*VT100.translations: #override \n\
Shift <Key>Return: string(0x1b) string("[27;2;13~")

For rxvt-unicode, I would add the following:

URxvt.keysym.S-Return: \033[27;2;13~

(Tested both of these.)


Then, in Vim, do something similar to this:

> Then map the 'currency' character to <S-CR> in Vim:
>
> | :map ¤ <S-CR>²

:map ^[[27;2;13~ <S-CR>
(where the first '^[' is a literal escape character)

You can type the first part of this line by doing:

i " insert mode
:map " normal characters
<Space>
<C-v> " insert literally See: :help i_CTRL-V
<S-CR> " shift + Enter
<Space>
(rest of line is just regular characters)

--
Best,
Ben

--
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

No comments:

Post a Comment