You are not logged in.

#1 2012-03-28 08:18:30

cryptkeeper
Member
From: Zurich, Switzerland
Registered: 2011-12-29
Posts: 63

latex-suite: disable smart key mappings (e.g. ... -> \ldots)

I've recently started using LaTeX. Since vim/Gvim is my absolutely favorite text editor, it's plugin latex-suite comes in handy with features such as text folding. Latex-suite also has some auto-completion/conversion features; unfortunately I don't like them. The most annoying are conversions such as ... -> \ldots. While this may be useful when using ... inside a text, it definitely isn't when trying to format the LaTeX document with ............. lines because they are automatically converted to \ldots\ldots\ldots!!!

I've already found out that this feature is called "Smart Dots" (see http://vim-latex.sourceforge.net/docume … suite.html --> "3.9. Smart Key Mappings"). Here http://vim-latex.sourceforge.net/docume … -keys.html it is described how to disable some of the smart key mappings; unfortunately, not the Smart Dots.

Any idea how to disable Smart Dots or even all auto-completion/conversion features in general? I generally don't like auto-completion/conversion!

Offline

#2 2012-03-28 09:09:36

portix
Member
Registered: 2009-01-13
Posts: 757

Re: latex-suite: disable smart key mappings (e.g. ... -> \ldots)

I don't know if it is possible to disable auto-completion in general but smart dots can be disabled with

let g:Tex_SmartKeyDot=0

Last edited by portix (2012-03-28 09:09:58)

Offline

#3 2012-03-28 10:19:39

cryptkeeper
Member
From: Zurich, Switzerland
Registered: 2011-12-29
Posts: 63

Re: latex-suite: disable smart key mappings (e.g. ... -> \ldots)

Thanks. Actually, it really starts to suck that Latex-suite always auto-inserts stuff. I could probably disable it step-by-step, but that would take time I don't have right now.

Strangely enough, it only auto-inserts stuff in Gvim, not in terminal vim...

How can I uninstall latex-suite? I looked into .vim, but there's nothing in it, and it's not a package... I don't remember how I installed it, either.

Edit: I still don't know how to actually uninstall it, but I found out I can disable it by removing (or out-commenting) the respective lines in .vimrc. That's perfect for now. I can work withouth the distractions by Latex-suite, and if I have time to customize Latex-suite according to my needs, I can enable it again to use the great folding feature.

BTW: I couldn't disable the auto-replacing of ... by \ldots with the command above (at least not by using it directly in Gvim)...

Last edited by cryptkeeper (2012-03-28 11:02:47)

Offline

#4 2012-03-28 11:07:24

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: latex-suite: disable smart key mappings (e.g. ... -> \ldots)

If you do go the route of removing latex-suite and reimplimeneting just the parts you want, I could share some vimrc snippets that I've made for just the same reason.

OK, not exactly the same - I never tried latex-suite.  I prefer the DIY methods because its a bit of fun, easily customizable, and I have complete control over which 'features' are implemented or not.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#5 2012-03-28 11:12:51

cryptkeeper
Member
From: Zurich, Switzerland
Registered: 2011-12-29
Posts: 63

Re: latex-suite: disable smart key mappings (e.g. ... -> \ldots)

Trilby wrote:

If you do go the route of removing latex-suite and reimplimeneting just the parts you want, I could share some vimrc snippets that I've made for just the same reason.

OK, not exactly the same - I never tried latex-suite.  I prefer the DIY methods because its a bit of fun, easily customizable, and I have complete control over which 'features' are implemented or not.

That sounds great! As mentioned, the only feature I really want at the moment is the folding feature (i.e. hiding whole sections, subsections etc... which is convenient in large documents). If you knew a way to implements only this, that would be awesome.

Actually, I'd like to take a look at your code snippets anyway, there may be something useful that I haven't thought of yet.

Offline

#6 2012-03-28 11:31:39

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: latex-suite: disable smart key mappings (e.g. ... -> \ldots)

Yup.  That's on my office computer - I'll post some bits later today.

I have a "generic" code-folding function I use which in turn uses a few variables to determine where to put the fold.  These variables are then set from autoCommands for each file type.  I forgot to disclose, however, that I don't use global folding bindings - eg when you want to collapse or expand all possible folds.  I just bind 'space' in normal mode to expand or collapse the fold point under the cursor (or the nearest one if there isn't one under the cursor).

I've actually only recently got started with latex - so I haven't fully customized this for tex files yet, but it will be fun to tinker a bit more today to get it to recognize \begin{X} \end{X} as fold-boundaries.  So far I've just put comment lines like

%----- {{{ CHAPTER 1 ---------------------------------------------
\chapter{chapter title}
%more stuff here
%----- }}} END CHAPTER 1 ---------------------------------------

  This works great, but the begin/end boundary recognition will be easy to implement.

I also have a version of the folding function that uses indent level to determine nesting.  This was made for python-like languages and works great.  If your latex files stick to using indentation levels for nested content that version of the function would work "out of the box".

Again, I'll put them up later today - if nothing else they may serve as a starting point to inspire better ideas.

EDIT: I just realized my example was all wrong - "begin{chapter}" I shall go make penance for such a foolish entry.  Anyhow, the point should have been clear.

Last edited by Trilby (2012-03-31 02:37:48)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#7 2012-03-28 11:44:52

bohoomil
Member
Registered: 2010-09-04
Posts: 2,376
Website

Re: latex-suite: disable smart key mappings (e.g. ... -> \ldots)

You may also want to look into the source files, where all the stuff begins, and modify them accordingly. The one of your interest would be

$VIMRUNTIME/ftplugin/latex-suite/main.vim

Last edited by bohoomil (2012-03-28 11:45:24)


:: Registered Linux User No. 223384

:: github
:: infinality-bundle+fonts: good looking fonts made easy

Offline

#8 2012-03-28 15:15:59

cryptkeeper
Member
From: Zurich, Switzerland
Registered: 2011-12-29
Posts: 63

Re: latex-suite: disable smart key mappings (e.g. ... -> \ldots)

Trilby wrote:

Yup.  That's on my office computer - I'll post some bits later today.
...

Sounds great, thanks a lot. But no need to hurry, I won't start to look at these things for a few days as I need my time at the moment. If I've learned one thing since I've switched to linux, it's never to start tweaking around things when I don't have very, very much time to waste 'cause I always need it! ^^

But it's awesome to have this input around for when I have time enough to take a closer look at it.

You may also want to look into the source files, where all the stuff begins, and modify them accordingly. The one of your interest would be

$VIMRUNTIME/ftplugin/latex-suite/main.vim

I would have looked at the source files if I knew where they are! In examples I found on google, they were in .vim/ftplugin/..., but as mentioned in the opening post, there's nothing latex-suite related in my .vim folder, and $VIMRUNTIME is not set either (I just checked with `echo $VIMRUNTIME`), and there's no hint to where latex-suite files are stored... Any ideas where this stuff could be?

Last edited by cryptkeeper (2012-03-28 15:17:19)

Offline

#9 2012-03-28 15:57:24

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: latex-suite: disable smart key mappings (e.g. ... -> \ldots)

It turns out this isn't QUITE as simple as I thought.  Since some latex elements are closed (eg \begin{something} ... \end{same something}) while others are not (eg \chapter \section) the folding function needs to check for each.

First here is my generic folder

function ToggleFold(marker)
    if foldlevel('.') == 0
        normal 0
        call search(a:marker,'c')
        let x = line('.')
        normal %
        let y = line('.')
        execute x . "," . y . " fold"
    else
        if a:marker == '<'
            normal k
            let x = line('.')
            normal j
            normal zd
            execute x
            normal j
        else
            normal zd
            normal %
        endif
    endif
endfunction

"some example bindings
nmap <space> ;call ToggleFold("{")<CR>
" } This is just here to match/close the previous line
au BufNewFile,BufRead *.svg set filetype=xml
au FileType html,xml nmap <space> ;call ToggleFold("<")<CR>
au FileType html,xml let b:match_words = '<\([^ >]*\)[^>]*>:</\1>'

And the whitespace or python-like code folder

function ToggleIndentFold()
    if foldlevel('.') == 0
        let x = line('.')
        let i = indent('.')
        normal j
        while indent('.') > i
            normal j
        endwhile
        normal k
        let y = line('.')
        execute x . "," . y . " fold"
    else
        normal zd
    endif
endfunction
"" The above function may hang in the while loop if
"" the file does not have a trailing empty line.
"" The following function checks for and/or adds one.
function StartOutline()
    let x = line('.')
    normal G
    if indent('.') != 0
        normal o
        execute x
    endif
endfunction

The challenge is parts of each of these would be needed for "complete" latex folding.  The begin/end bounded blocks can use the generic function with these line

au BufNewFile,BufRead *.tex nmap <space> ;call ToggleFold("\begin")<CR>
au BufNewFile,BufRead *.tex let b:match_words = 'begin{\([a-z]*\)}:end{\1}'

but this will not fold "unbounded" blocks like chapter section and item.

Here is my first attempt at a general purpose latex folder.  It works ... most of the time.

function ToggleLatexFold()
    if foldlevel('.') == 0
        let block_type = matchstr(getline('.'),'\(chapter\|section\|item\)')
        if block_type != ""
            " I don't like the next four lines - there should be a better way of
            "    getting the number of lines in the buffer
            normal ma
            normal G
            let last_line = line('.')
            normal `a
            " end ugliness
            let x = line('.')
            normal j
            while matchstr(getline('.'),block_type) != block_type
                if line('.') >= last_line
                    break
                endif
                normal j
            endwhile
            normal k
            let y = line('.')
            execute x . "," . y . " fold"
        else
            normal 0
            call search("\begin{",'c')
            let x = line('.')
            normal %
            let y = line('.')
            execute x . "," . y . " fold"
        endif
    else
        normal zd
        normal %
    endif
endfunction

au BufNewFile,BufRead *.tex nmap <space> ;call ToggleLatexFold()<CR>
au BufNewFile,BufRead *.tex let b:match_words = 'begin{\([a-z]*\)}:end{\1}'

It fails, however, when a section is followed a new chapter rather than another section.  This part would be easy to fix.  It also fails, though, when a same-flavor block is nested within the current - for example a \item that has a nested enumerate or itemize will not fold properly.

For my use, I'll stick with putting braces in comments around my major elements.  But hopefuly this will give you some ideas.  If you make any big improvements, let me know.

No doubt I have really just reinvented the wheel - but thats the best way to really know how wheels work!


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#10 2012-03-28 18:30:59

bohoomil
Member
Registered: 2010-09-04
Posts: 2,376
Website

Re: latex-suite: disable smart key mappings (e.g. ... -> \ldots)

cryptkeeper wrote:

there's nothing latex-suite related in my .vim folder, and $VIMRUNTIME is not set either (I just checked with `echo $VIMRUNTIME`)

Run this

:echo $VIMRUNTIME

when inside Vim, and it should point to /usr/share/vim/ by default. You probably have all your plugins installed right there (latex-suite occupies several directories: ./compiler, ./doc, ./ftplugin, ./indent, and ./plugin). The file you're looking for should be in

/usr/share/vim/vim73/ftplugin/latex-suite/main.vim

Searching for 'dots' should show you to the relevant pieces.

BTW, to make things easier with Vim plugins, I strongly recommend that you use an extension called Pathogen which lets you easily organize all your extensions simply by putting them in one dedicated directory inside your $HOME/.vim/. Such an approach is a real time saver while remaining fully functional and compatible with Vim standards.

*) There's also another one that does the same, called Vundle, but I've never used it myself.

Last edited by bohoomil (2012-03-28 18:32:35)


:: Registered Linux User No. 223384

:: github
:: infinality-bundle+fonts: good looking fonts made easy

Offline

#11 2012-03-31 01:04:50

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,152

Re: latex-suite: disable smart key mappings (e.g. ... -> \ldots)

cryptkeeper wrote:

I've recently started using LaTeX. Since vim/Gvim is my absolutely favorite text editor, it's plugin latex-suite comes in handy with features such as text folding. Latex-suite also has some auto-completion/conversion features; unfortunately I don't like them. The most annoying are conversions such as ... -> \ldots. While this may be useful when using ... inside a text, it definitely isn't when trying to format the LaTeX document with ............. lines because they are automatically converted to \ldots\ldots\ldots!!!

I am no great fan of autocompletion/conversion myself. (I just had to find and undo every single case of LibreOffice Writer "autocorrecting" occurrences of the word "i" and change them back. I was completing a job application form. "i" isn't supposed to inevitably be "I" in every language!)

That said, however you do it, you really don't want to be typing ".............." in LaTeX. There are commands for producing dotted lines which will result in much better output and you really should use those. (Exception: if you are using LaTeX solely because you are required to and you just want to get the job done, fair enough. But if you are using it because it typesets beautifully, you should.)

Have you tried \dotfill?


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#12 2012-03-31 08:11:47

cryptkeeper
Member
From: Zurich, Switzerland
Registered: 2011-12-29
Posts: 63

Re: latex-suite: disable smart key mappings (e.g. ... -> \ldots)

cfr wrote:

That said, however you do it, you really don't want to be typing ".............." in LaTeX. There are commands for producing dotted lines which will result in much better output and you really should use those. (Exception: if you are using LaTeX solely because you are required to and you just want to get the job done, fair enough. But if you are using it because it typesets beautifully, you should.)

Have you tried \dotfill?

I think you get me wrong here! Of course I don't mean formatting the documents itself with dotted lines etc., I'm only about formatting the code!! The dotted lines are commented out and only serve the purpose of making the source file more clearly arranged. If I would be talking about using dotted lines in the final PDf file, I wouldn't have a problem with \ldots in the source file, would I? wink

An example how I "decorate" the begin of a new section:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{New section!!} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\label{sec:new_section} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

For subsection and subsubsections, I use other symbols (///////// and -------, respectively), so I can easily scroll through the file from section to section.

Last edited by cryptkeeper (2012-03-31 08:12:23)

Offline

#13 2012-04-10 11:31:12

aurinkolasit
Member
Registered: 2009-07-02
Posts: 27

Re: latex-suite: disable smart key mappings (e.g. ... -> \ldots)

Hello,

Actually, Vim can fold your document based on LaTeX syntax. Just set

g:tex_fold_enabled = 1

and make sure 'fdm' is set to 'syntax'.

Regarding your auto complete issue, make sure that you're pasting text from the clipboard with the + register. I don't know why, but pasting with the * register does activate some keybindings in my case.

*Shameless ad*

I'm the author of TeX_9

http://www.vim.org/scripts/script.php?script_id=3508

...You might want to check it out. It shares some of the ideas with Vim LaTeX suite but its code base is a whole lot smaller. Most importantly I tried to reduce the mental effort of learning a lot of keybindings. It does auto complete parens and the like with a logic that suits me but you can change it in your .vimrc.

*End of  shameless ad*

Offline

Board footer

Powered by FluxBB