Tuesday, March 29, 2011

Re: Function to write correctly French quotation marks

Le 29-03-2011, à 02:50:47 -0400, Benjamin R. Haskell (vim@benizi.com) a écrit :

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

Ah ok, thanks (feeling so lonely suddenly...:-))

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

I gave it a try, and it works. But:

- I need to press <"> before typing the work and <'> at the end of the
word, not very convenient if I have to go through a file to correct it
(in normal mode for instance).

- I can not use those two keys anymore (I had to select from visual mode
what you had written, yank it, and then paste it in order to write
them in this message).

- it would be easier to place the cursor under a word (or visual select
several words) and then hit a key to achieve my goal).


I see that Christian answered too, so I will (can not write single quote
anymore ;-)) go through his message and come back later.


Thanks for your reply Ben, very informative. The more I learn vim, the
more I understand how far I am from mastering it (did not Einstein say
something like that?)

Have a nice day,
steve

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