On 09/12/11 16:27, Ben Fritz wrote:
I'm a little stumped by a problem brought to light by a recent edit to
http://vim.wikia.com/wiki/Using_Vim_with_the_Dvorak_keyboard_layout
:help 'langmap' says:
The 'langmap' option is a list of parts, separated with commas. Each
part can be in one of two forms:
1. A list of pairs. Each pair is a "from" character immediately
followed by the "to" character. Examples: "aA", "aAbBcC".
2. A list of "from" characters, a semi-colon and a list of "to"
characters. Example: "abc;ABC"
Example: "aA,fgh;FGH,cCdDeE"
Special characters need to be preceded with a backslash. These are
";", ',' and backslash itself.
The tip linked above tries to set 'langmap' to include a mapping of
the comma key to a w (because in Dvorak, you press what would be a
comma in QWERTY to get a w, and vice versa).
From the :help entry, I and the tip author would type the following to
accomplish this:
:set langmap=\,w
However, doing so gives:
E357: 'langmap': Matching character missing for w
This works, but I cannot justify why it would be needed:
:set langmap=\\,w
And, as a related problem, this means you need to type FOUR
backslashes to get a single backslash in a langmap. This seems wrong.
e.g. this gives the same error as above:
:set langmap=\\h
But this works:
:set langmap=\\\\h
Am I missing something here? It's certainly surprising behavior that
should be documented if intentional, but I'm not confident it's a
bug...yet.
Vim 7.3.353 "Vim without Cream" build.
What you are missing is documented under :help option-backslash
In order to get a backslash in the value of an option, you need two in
the :set statement; in order to get two, you need four. Similarly, if
you want a space, a tab or a vertical bar to be part of the value of an
option, you need backslash-escaping in the :set statement.
When it is said under 'langmap' that "special characters must be
preceded by a backslash", it means they must be preceded by a backslash
in the _value_ of the option; but _setting_ that value already halves
the number of backslashes in the :set command.
If you want the langmap to change a comma to a w, you need to
backslash-escape the comma so it isn't used as a separator. This is done
by using
:set langmap=\\,w
or
:let &langmap = '\,w'
which are equivalent.
Similarly, to change a backslash to an h, you need
:set langmap=\\\\h
or
:let &langmap = '\\h'
because a backslash-escaped backslash must remain in the value of the
option.
Best regards,
Tony.
--
"It's a small world, but I wouldn't want to have to paint it."
-- Steven Wright
--
You received this message from the "vim_dev" 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