20

I use Vim with Vim-Latex plugin to edit my LaTeX documents. I have the problem that whenever I want to insert a double quote ("), it automatically get replace by (``). Any idea how can I disable that while still having Vim-Latex enabled?

Rafid
  • 5,717

3 Answers3

12

Add let g:Tex_SmartKeyQuote=0 to $VIM/ftplugin/tex.vim (create that file if necessary), where $VIM corresponds to ~/.vim for unixy operating systems and ~/vimfiles for Windows.

There are more configuration variables, see the latexsuite manual.

Caramdir
  • 89,023
  • 26
  • 255
  • 291
  • Thanks man. But to be honest, I liked it that it replaces " with ``, but the thing is that I wanted to disable it because it would do that even in comments. Is there anyway around that?! That is, keep it enabled, but disable it when I want with a short-cut key or something like that. – Rafid Jan 08 '11 at 22:08
  • 2
    I don't know. Actually, I would recommend to use \enquote from the csquotes package instead of `` and ''. – Caramdir Jan 08 '11 at 22:11
  • 14
    You can always use CTRL+V" to insert " without expansion. See :he i_CTRL-V for details. – Aditya Jan 09 '11 at 01:41
  • 2
    @Aditya That should probably be an answer, since it addresses his problem perfectly. I think it's exactly what he was looking for since he specifically asked for a "short-cut key". – Adrian Petrescu Jan 09 '11 at 07:36
  • Pasting a " still expanded to ``, but if you first do setl paste, the double quote will be pasted as intended. – Bram Schoenmakers Jul 12 '12 at 12:50
9

I usually type \", since in that context the " is not replaced by "smart quotes," and then delete the \. This is convenient enough for me, since I rarely need the " character, and I don't want to change Vim-LaTeX's default behavior.

Luke M
  • 91
3

I know you already accepted an answer, but just for those who use vim for LaTeX, but (like me) don't use the Vim-LaTeX plugin, I use the following, which I put inside my personal $HOME/.vim/ftplugin/tex.vim. It handles quotation marks pretty well (at least for my purposes), and deactivates itself in comments and following \. I began with some code from the "auctex.vim" plugin, but have I have added a lot to it and customized it a lot myself.

" Function for smart-quotes: double
function! s:TexQuotes()
    if getline('.')[0:col(".")] =~ '\(^\|[^\\]\)%'
       let kinsert = "\""
    else
        let kinsert = "\'\'"
        let left = getline('.')[col('.')-2]
        if left =~ '^\(\|\s\|{\|(\|\[\|&\)$'
            let kinsert = "\`\`"
        elseif left == "\\"
            let kinsert = "\""
        endif
    endif
    return kinsert
endfunction
" mapping for quotation marks
inoremap <buffer> " <C-R>=<SID>TexQuotes()<CR>
" Function for smart-quotes: single
function! s:TexSingQuotes()
    if getline('.')[0:col(".")] =~ '\(^\|[^\\]\)%'
       let schminsert = "'"
    else
        let schminsert = "'"
        let left = getline('.')[col('.')-2]
        if left =~ '^\(\|\s\|{\|(\|\[\|&\)$'
            let schminsert = '`'
        endif
    endif
    return schminsert
endfunction
" mapping for single quotation mark
inoremap <buffer> ' <C-R>=<SID>TexSingQuotes()<CR>

This could probably be cleaned up a bit. I wrote it when I was first learning the tiny bit of vimscript language that I know.

You could probably use it alongside the vim-latex plugin, so long as you disable its smart-quote feature, but I haven't tried.

frabjous
  • 41,473