>
> Hi Christian,
>
> Thank you for your answer.
>
> Le 23-03-2011, à 17:57:53 +0100, Christian Brabandt a écrit :
>
>> On Wed, March 23, 2011 3:20 pm, Steve wrote:
>
>>> In French, we do not write "word" or 'word', we write « word », with 
>>> a non-breakable space after « and before ». Until now, I do:
>>>
>>> <c-k><<<c-k>NSword<c-k>NS<c-k>>>
>>>
>>> which is really not convenient. I'd like a function, say 
>>> Guillemets(), which does that automatiquelly. I would then map it to 
>>> a function key FN (or whatever else) and just call it in normal 
>>> mode. Problem, I really don't have the necessary skills to do that.
>>>
>>> Anybody could help?
>>
>> Does those two mappings help you?
>>
>> :imap <expr> " getline('.')[col('.')-2]=~'\S' ?  ' »' : '« '
>> :imap <expr> ' getline('.')[col('.')-2]=~'\S' ?  ' »' : '« '
>
> In fact, both don't do anything. I replaced <expr> by <F10> or 
> <Leader>gu, but nothing happens.
'<expr>' isn't something to be replaced. See:
:help :map-<expr>
(Basically, without the '<expr>' in front, you'll get the mappings as 
literal commands, which is not what you want.)
These mappings are to the keys <"> and <'>.  If you want them mapped to 
something else, change those single characters.  But you probably don't 
want to do that.  These are :*i*map commands (i = insert).  So, they're 
active while in Insert mode.  They change the meanings of the keys <"> 
and <'> to "smartly" insert guillemets.
E.g. typing: Hi, "this is in quotes," and "so is this".
You end up with: Hi, « this is in quotes, » and « so is this ».
Give it a try, but you'll probably want to set up some kind of toggle so 
that the mappings aren't active 100% of the time.
-- 
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