18

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?

2
  • 1
    Try pressing " twice in a row, that should give you back the non-smart quote...
    – Seamus
    Jan 9, 2011 at 11:40
  • 4
    Nope, this does not work.
    – math
    Apr 3, 2014 at 11:36

3 Answers 3

11

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.

5
  • 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 8, 2011 at 22:08
  • 2
    I don't know. Actually, I would recommend to use \enquote from the csquotes package instead of `` and ''.
    – Caramdir
    Jan 8, 2011 at 22:11
  • 14
    You can always use CTRL+V" to insert " without expansion. See :he i_CTRL-V for details.
    – Aditya
    Jan 9, 2011 at 1: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". Jan 9, 2011 at 7:36
  • Pasting a " still expanded to ``, but if you first do setl paste, the double quote will be pasted as intended. Jul 12, 2012 at 12:50
8

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.

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.