Encoding of double quotes by Vim

341 views
Skip to first unread message

Eric Weir

unread,
Aug 4, 2012, 7:19:40 AM8/4/12
to vim_use

I write in Vim and when ready to format/publish dump documents in LyX for formatting as LaTeX documents. When I do so, double quotes show up in LyX with closing quotes at the beginning and end of the quote. When dumped in a word processor, opening and closing quotes are identical as well, but they are the vertical quotation marks, not the ones that curve in and out that is standard in LyX. I'm guess the latter is what is meant by "smart quotes."

I'm wondering if it's possible to change the encoding of double quotes in Vim so they don't get translated the way they do in LyX. 

Thanks,
------------------------------------------------------------------------------------------
Eric Weir
Decatur, GA

"What is man without the beasts? If all the beasts were gone, 
men would die from a great loneliness of spirit." 

- Chief Seattle






Tony Mechelynck

unread,
Aug 4, 2012, 9:26:24 AM8/4/12
to vim...@googlegroups.com, Eric Weir
On 04/08/12 13:19, Eric Weir wrote:
>
> I write in Vim and when ready to format/publish dump documents in LyX
> for formatting as LaTeX documents. When I do so, double quotes show up
> in LyX with closing quotes at the beginning and end of the quote. When
> dumped in a word processor, opening and closing quotes are identical as
> well, but they are the vertical quotation marks, not the ones that curve
> in and out that is standard in LyX. I'm guess the latter is what is
> meant by "smart quotes."
>
> I'm wondering if it's possible to change the encoding of double quotes
> in Vim so they don't get translated the way they do in LyX.
>
> Thanks,
> ------------------------------------------------------------------------------------------
> Eric Weir
> Decatur, GA
> eew...@bellsouth.net <mailto:eew...@bellsouth.net>

Vim's double quotes are Latin1 0x22, Unicode U+0022 QUOTATION MARK;
Unicode adds about them:
* neutral (vertical), used as opening or closing quotation mark
* preferred characters in English for paired quotation marks are U+201C
� and U+201D �.

If LyX modifies your neutral (") quotation marks to make them closing
ones (�) that's a LyX problem, not a Vim problem.

If you want to be able to type �pretty� quotation marks in Vim (as I
just did here in my mailer), there are several possibilities:
- find out if your keyboard has them (on mine, it's AltGr+v and AltGr+b)
- use Ctrl-V u 201c and Ctrl-V u 201d (see :help i_CTRL-V_digit)
- make up (or find) a keymap which has them, see
http://vim.wikia.com/wiki/How_to_make_a_keymap
- make Insert-mode mappings for them, for instance (with the � and �
single quotes for good measure):

" double opening quote
map! <F6> <Char-0x201C>
" double closing quote
map! <F7> <Char-0x201D>
" single opening quote
map! <S-F6> <Char-0x2018>
" single closing quote
map! <S-F7> <Char-0x2019>

and put them in your vimrc (see :help <Char> about the values I used
above in the {rhs} of the mappings). The above assumes that 'encoding'
has been set to UTF-8 before you define those mappings, see
http://vim.wikia.com/wiki/Working_with_Unicode


Best regards,
Tony.
--
Don't cook tonight -- starve a rat today!

Tony Mechelynck

unread,
Aug 4, 2012, 9:34:21 AM8/4/12
to vim...@googlegroups.com, Eric Weir
Oh, and I forgot: use Ctrl-K "6 and Ctrl-K "9 (see :help digraphs-use)

> - make up (or find) a keymap which has them, see
> http://vim.wikia.com/wiki/How_to_make_a_keymap
> - make Insert-mode mappings for them, for instance (with the � and �
> single quotes for good measure):
>
> " double opening quote
> map! <F6> <Char-0x201C>
> " double closing quote
> map! <F7> <Char-0x201D>
> " single opening quote
> map! <S-F6> <Char-0x2018>
> " single closing quote
> map! <S-F7> <Char-0x2019>
>
> and put them in your vimrc (see :help <Char> about the values I used
> above in the {rhs} of the mappings). The above assumes that 'encoding'
> has been set to UTF-8 before you define those mappings, see
> http://vim.wikia.com/wiki/Working_with_Unicode
>
>
> Best regards,
> Tony.
--
Ass, n.:
The masculine of "lass".

Alick Zhao

unread,
Aug 5, 2012, 4:27:19 AM8/5/12
to vim...@googlegroups.com, Eric Weir
On Sat, 4 Aug 2012 07:19:40 -0400, Eric Weir wrote:
>
> I write in Vim and when ready to format/publish dump documents in LyX
> for formatting as LaTeX documents. When I do so, double quotes show up
> in LyX with closing quotes at the beginning and end of the quote. When
> dumped in a word processor, opening and closing quotes are identical as
> well, but they are the vertical quotation marks, not the ones that curve
> in and out that is standard in LyX. I'm guess the latter is what is
> meant by "smart quotes."
>
> I'm wondering if it's possible to change the encoding of double quotes
> in Vim so they don't get translated the way they do in LyX.
>

As Tony puts, it should be an issue of LyX rather than Vim. However I
want to add that LyX use LaTeX as its backend and LaTeX has its rule of
typesetting quotes. You need to use `(backtick, or the grave sign) and
'(single quote) to specify a beginning quote and a closing quote. And
for the double quotes you need to say `` and ''(not " sign).

Hope this helps.

--
alick
Fedora 16 (Verne) user
https://fedoraproject.org/wiki/User:Alick

Eric Weir

unread,
Aug 5, 2012, 5:00:36 PM8/5/12
to Alick Zhao, vim...@googlegroups.com

On Aug 5, 2012, at 4:27 AM, Alick Zhao wrote:

> As Tony puts, it should be an issue of LyX rather than Vim. However I
> want to add that LyX use LaTeX as its backend and LaTeX has its rule of
> typesetting quotes. You need to use `(backtick, or the grave sign) and
> '(single quote) to specify a beginning quote and a closing quote. And
> for the double quotes you need to say `` and ''(not " sign).

Thanks, Alick. So using backticks in Vim would avoid the problem in LyX I'll give it a try.

From my communication with the LyX folks I understand there's been a long-standing request for addressing this issue, and more generally to provide more flexibility in the use of commas. Again, as I understand it, I think they're talking about getting LyX to use a LaTeX package called 'csquote.' People seem to be saying it wouldn't be that difficult.

Apart from that, it's been suggested that I might be able to make use of the package myself. I've looked at the documentation, but don't have a good sense of what the possibilities might be yet.

------------------------------------------------------------------------------------------
Eric Weir
eew...@bellsouth.net

"The invincible shield of caring
Is a weapon sent from the sky
against being dead."

- Tao Te Ching 67







Eric Weir

unread,
Aug 5, 2012, 5:16:20 PM8/5/12
to Tony Mechelynck, vim...@googlegroups.com

On Aug 4, 2012, at 9:26 AM, Tony Mechelynck wrote:

> Vim's double quotes are Latin1 0x22, Unicode U+0022 QUOTATION MARK; Unicode adds about them:
> * neutral (vertical), used as opening or closing quotation mark
> * preferred characters in English for paired quotation marks are U+201C “ and U+201D ”.
>
> If LyX modifies your neutral (") quotation marks to make them closing ones (”) that's a LyX problem, not a Vim problem.

Thanks for the information on what Vim does, Tony. As my response to Alick indicates, the LyX folks are aware of the problem and that it is their's.

> If you want to be able to type “pretty” quotation marks in Vim (as I just did here in my mailer), there are several possibilities:
> - find out if your keyboard has them (on mine, it's AltGr+v and AltGr+b)

Actually, my preference would be to have LyX use the character Vim uses, the way the word processors I've checked out on this do when I dump a Vim-composed document into them.

I'll stay open to the option of setting up a mapping.

I don't understand 'AltGr+v'. Specifically, the 'Gr' part.

Thanks again,
------------------------------------------------------------------------------------------
Eric Weir
Decatur, GA
eew...@bellsouth.net

Gary Johnson

unread,
Aug 5, 2012, 5:41:50 PM8/5/12
to vim...@googlegroups.com
On 2012-08-05, Eric Weir wrote:

> I'll stay open to the option of setting up a mapping.

You may want to consider the Vim LaTeX Suite at
http://www.vim.org/scripts/script.php?script_id=475 or
http://vim-latex.sourceforge.net/. When you type ", it
automatically substitutes `` or '' as it decides is appropriate.

Regards,
Gary

Tim Gray

unread,
Aug 5, 2012, 6:13:52 PM8/5/12
to vim...@googlegroups.com
On Aug 05, 2012 at 05:16 PM -0400, Eric Weir wrote:
>Thanks for the information on what Vim does, Tony. As my response to
>Alick indicates, the LyX folks are aware of the problem and that it is
>their's.

I think the point people are trying to make that a) it's a property of
LyX and not Vim and b) it's not necessarily a 'problem' in LyX. If LyX
is using TeX for it's typesetting, the way you type open and closing
quotes is with ` and ' as said before (and `` and '' for double quotes).
It's not 'fixing' the problem to do it that way - it's doing it properly
that way. Typing a sentence like this with a "word" in quotes is wrong.
First, I used a " and not '', and second, I need to specify the opening
and closing quotes using ` or ' as appropriate. Note, where I typed
'problem' and 'fixing' in this email wouldn't format correctly in TeX,
but that's ok, because this is an email.

As stated by someone else, you might want to try the Vim package that
inserts the right quote while typing TeX for you, or you could just type
it correctly yourself. It's possible that there is a TeX package that
does smart quoting for you, but I'm not aware if there is. I'm also not
familiar with how (and if) you can add packages to LyX. I use LaTeX
myself quite a bit, but I just call it from Vim with a keymap and
preview it in Skim, so have never found the need for LyX. No need to
paste any of my text/source into another program that way.

Tony Mechelynck

unread,
Aug 5, 2012, 7:34:26 PM8/5/12
to Eric Weir, vim...@googlegroups.com
On 05/08/12 23:16, Eric Weir wrote:
>
> On Aug 4, 2012, at 9:26 AM, Tony Mechelynck wrote:
>
>> Vim's double quotes are Latin1 0x22, Unicode U+0022 QUOTATION MARK; Unicode adds about them:
>> * neutral (vertical), used as opening or closing quotation mark
>> * preferred characters in English for paired quotation marks are U+201C � and U+201D �.
>>
>> If LyX modifies your neutral (") quotation marks to make them closing ones (�) that's a LyX problem, not a Vim problem.
>
> Thanks for the information on what Vim does, Tony. As my response to Alick indicates, the LyX folks are aware of the problem and that it is their's.
>
>> If you want to be able to type �pretty� quotation marks in Vim (as I just did here in my mailer), there are several possibilities:
>> - find out if your keyboard has them (on mine, it's AltGr+v and AltGr+b)
>
> Actually, my preference would be to have LyX use the character Vim uses, the way the word processors I've checked out on this do when I dump a Vim-composed document into them.
>
> I'll stay open to the option of setting up a mapping.
>
> I don't understand 'AltGr+v'. Specifically, the 'Gr' part.
>
> Thanks again,

On my (Belgian) keyboard, I said, � is AltGr+v and � is AltGr+b. IOW, to
get � I hold down AltGr (but not Shift) while pressing and releasing v,
to get � I hold down AltGr (but not Shift) while pressing and releasing
b. Your keyboard may or may not have an AltGr key; on mine, it's the key
immediately to the right of the space bar, and AltGr is printed on it. I
suppose that on some other keyboards the key at the same position is
named "the right Alt key". I've been told (but I don't know for sure)
that on keyboards without an AltGr key you get the same effect by using
both Ctrl and Alt modifiers together.

Just for fun (and for the RTFM effect), I looked up AltGr on Wikipedia,
and found it; maybe the page would interest you:
http://en.wikipedia.org/wiki/AltGr

The fact that there is no obvious relationship between � and v, � and b,
makes me believe that the same "special key combination" could quite
possibly give the same result in many other "national keyboards"
(especially since V and B are in the same locations on all three of
AZERTY, QWERTZ and QWERTY keyboard arrangements).


Best regards,
Tony.
--
"Approximately 80% of our air pollution stems from hydrocarbons
released by vegetation, so let's not go overboard in setting and
enforcing tough emissions standards from man-made sources."
-- Ronald Reagan

Eric Weir

unread,
Aug 6, 2012, 12:15:14 PM8/6/12
to Tony Mechelynck, vim...@googlegroups.com

On Aug 5, 2012, at 7:34 PM, Tony Mechelynck wrote:

> On my (Belgian) keyboard, I said, “ is AltGr+v and ” is AltGr+b. IOW, to get “ I hold down AltGr (but not Shift) while pressing and releasing v, to get ” I hold down AltGr (but not Shift) while pressing and releasing b. Your keyboard may or may not have an AltGr key; on mine, it's the key immediately to the right of the space bar, and AltGr is printed on it. I suppose that on some other keyboards the key at the same position is named "the right Alt key". I've been told (but I don't know for sure) that on keyboards without an AltGr key you get the same effect by using both Ctrl and Alt modifiers together.
>
> Just for fun (and for the RTFM effect), I looked up AltGr on Wikipedia, and found it; maybe the page would interest you:http://en.wikipedia.org/wiki/AltGr
>
> The fact that there is no obvious relationship between “ and v, ” and b, makes me believe that the same "special key combination" could quite possibly give the same result in many other "national keyboards" (especially since V and B are in the same locations on all three of AZERTY, QWERTZ and QWERTY keyboard arrangements).

Thanks for the explanation, Tony. The wikipedia article says that on a mac---US keyboard I take it---the option key functions the way AltGr does.

When I do Option+v and Option+b I get, respectively, √ and ∫. When I do Shift+Option+v and +b I get ◊ and ı.

When I do Ctrl+Option+v and +b I get <Right> and ^B respectively.

------------------------------------------------------------------------------------------
Eric Weir
Decatur, GA
eew...@bellsouth.net

"I have a mind-set that says bipartisanship ought to consist of
the Democrats coming to the Republican point of view."

- Richard Mourdock

Eric Weir

unread,
Aug 6, 2012, 12:27:12 PM8/6/12
to Eric Weir, Tony Mechelynck, vim...@googlegroups.com

On Aug 6, 2012, at 12:15 PM, Eric Weir wrote:

> The wikipedia article says that on a mac---US keyboard I take it---the option key functions the way AltGr does.

But the AltGr article has a link to the Option key on a Mac. With its help I found that Option+[ gives “ and Shitf+Option+[ gives ”.

Neither of those is more difficult than typing Shift+".

So thanks for leading me there, Tony.

------------------------------------------------------------------------------------------
Eric Weir
Decatur, GA USA
eew...@bellsouth.net

"Uncertainty is an uncomfortable position,
but certainty is an absurd one."

- Voltaire

Eric Weir

unread,
Aug 6, 2012, 12:30:11 PM8/6/12
to vim...@googlegroups.com

On Aug 5, 2012, at 5:41 PM, Gary Johnson wrote:

> You may want to consider the Vim LaTeX Suite at
> http://www.vim.org/scripts/script.php?script_id=475 or
> http://vim-latex.sourceforge.net/. When you type ", it
> automatically substitutes `` or '' as it decides is appropriate.

Hmm. Thanks. Since I'm trying to move to a Vim/LyX/LaTeX environment that might be in order anyway.

------------------------------------------------------------------------------------------
Eric Weir
Decatur, GA
eew...@bellsouth.net

"The problem with the world is that the intelligent people are
full of doubts while the stupid ones are full of confidence."

- Charles Bukowski





Eric Weir

unread,
Aug 6, 2012, 12:52:41 PM8/6/12
to vim...@googlegroups.com

On Aug 5, 2012, at 6:13 PM, Tim Gray wrote:

> On Aug 05, 2012 at 05:16 PM -0400, Eric Weir wrote:
>> Thanks for the information on what Vim does, Tony. As my response to Alick indicates, the LyX folks are aware of the problem and that it is their's.
>
> I think the point people are trying to make that a) it's a property of LyX and not Vim and b) it's not necessarily a 'problem' in LyX. If LyX is using TeX for it's typesetting, the way you type open and closing quotes is with ` and ' as said before (and `` and '' for double quotes). It's not 'fixing' the problem to do it that way - it's doing it properly that way. Typing a sentence like this with a "word" in quotes is wrong. First, I used a " and not '', and second, I need to specify the opening and closing quotes using ` or ' as appropriate.

Thanks for the clarification, Tim. I now have two ways to address the issue from within Vim, the TeX way---`` and ''---and the Mac way---Option+[ and Shift+Option+[. The former is not displayed in LyX but it compiles. The latter is displayed and it compiles.

> As stated by someone else, you might want to try the Vim package that inserts the right quote while typing TeX for you

I plan to do so.

> It's possible that there is a TeX package that does smart quoting for you, but I'm not aware if there is.

Maybe 'csquotes'? http://www.ctan.org/pkg/csquotes/

> I'm also not familiar with how (and if) you can add packages to LyX.

On a per document basis you can. I believe also in LyX per se. At least some packages.

> I use LaTeX myself quite a bit, but I just call it from Vim with a keymap and preview it in Skim, so have never found the need for LyX. No need to paste any of my text/source into another program that way.

An advantage of LyX---in addition to making LaTeX available to folks like me who can't code it---is that while composing and editing documents are more readable, since the LaTeX code is not displayed.

------------------------------------------------------------------------------------------
Eric Weir
Decatur, GA
eew...@bellsouth.net

"A writer is a person for whom writing is more difficult
than it is for other people."

- Thomas Mann






Reply all
Reply to author
Forward
0 new messages