Thread: [Vim-latex-devel] function to switch settings
Brought to you by:
srinathava,
tmaas
From: Andreas G. <and...@tu...> - 2014-02-26 10:09:19
|
Hi @ all, I am using vim latex suite for a while an I am quite happy with how it is working. I often have to switch between tex-projects in German (using pdflatex with biber) and project in English (using latex with bibtex). Hence, up to now I have to change the settings in my .vimrc before I start working on another project. These are my settings: "vim-latex plugin settings set grepprg=grep\ -nH\ $* let g:tex_flavor = 'latex' let g:Tex_BibtexFlavor = 'biber' " use biber instead of bibtex "let g:Tex_BibtexFlavor = 'bibtex' " using bibtex let g:Tex_UseMakefile = 0 let g:Tex_ShowErrorContext = 0 let g:Tex_AutoFolding = 0 let g:Tex_CompileRule_dvi = 'latex --interaction=nonstopmode $*' let g:Tex_CompileRule_ps = 'dvips -o $*.ps $*.dvi' let g:Tex_CompileRule_pdf = 'pdflatex --interaction=nonstopmode $*' let g:Tex_FormatDependency_ps = 'dvi,ps' let g:Tex_FormatDependency_pdf = 'pdf' let g:Tex_MultipleCompileFormats = 'dvi,ps,pdf' let g:Tex_DefaultTargetFormat = 'pdf' "let g:Tex_DefaultTargetFormat = 'ps' So before switching from a German to an English project a toggle the comments for the Tex_DefaultTargetFormat and the Tex_BibtexFlavor (and the spell checking options). Since this is quite inconvenient I thought about defining two function which do the job. I added :function German() : :set spell spelllang=de_20 : :let g:Tex_DefaultTargetFormat = 'pdf' : :let g:Tex_BibtexFlavor = 'biber' :endfunction autocmd FileType tex :command! German :cal German() :function English() : :set spell spelllang=en_gb : :let g:Tex_DefaultTargetFormat = 'ps' : :let g:Tex_BibtexFlavor = 'bibtex' :endfunction autocmd FileType tex :command! English :cal English() to my .vimrc. When I am calling the function English the spell checking and the bibliography settings are changed correctly. Even the default format is changed (checked by calling :TTarget) but it is not working as expected. After calling \ll a pdf file is still build, instead of a ps file. Sometimes (until now I could find out under which circumstance) a dvi is build, but not a ps like it should. Any ideas what is wrong with my function definition? What do I have to do in order to correctly change the default target from a function. Any hint is appreciated. Thanks and best regards. Andreas -- |
From: Francesco M. <fra...@gm...> - 2014-02-26 10:24:27
|
Hi Andreas, This might work: Put your default settings (e.g. English) in your .vimrc (or ftplugin/tex) file. In the directory where you want you use the other language (e.g. German) create a main.tex.latexmain file [1] (I'm assuming that the main latex file is main.tex). Then put in main.tex.latexmain: set spell spelllang=de_20 let g:Tex_DefaultTargetFormat = 'pdf' let g:Tex_BibtexFlavor = 'biber' This file is loaded after all the .vimrc and .vim/* files. I've used successfully this trick to compile with pdflatex specific projects, while keeping standard latex as default. Cheers, Fra ref: [1] http://vim-latex.sourceforge.net/documentation/latex-suite/latex-project.html ps: you might think about changing the spelllang only in the current buffer, in particular if you open different filetypes in the same session 2014-02-26 11:09 GMT+01:00 Andreas Groh <and...@tu...>: > Hi @ all, > > I am using vim latex suite for a while an I am quite happy with how it > is working. I often have to switch between tex-projects in German (using > pdflatex with biber) and project in English (using latex with bibtex). > Hence, up to now I have to change the settings in my .vimrc before I > start working on another project. These are my settings: > > "vim-latex plugin settings > set grepprg=grep\ -nH\ $* > let g:tex_flavor = 'latex' > let g:Tex_BibtexFlavor = 'biber' " use biber instead of bibtex > "let g:Tex_BibtexFlavor = 'bibtex' " using bibtex > let g:Tex_UseMakefile = 0 > let g:Tex_ShowErrorContext = 0 > let g:Tex_AutoFolding = 0 > > let g:Tex_CompileRule_dvi = 'latex --interaction=nonstopmode $*' > let g:Tex_CompileRule_ps = 'dvips -o $*.ps $*.dvi' > let g:Tex_CompileRule_pdf = 'pdflatex --interaction=nonstopmode $*' > > let g:Tex_FormatDependency_ps = 'dvi,ps' > let g:Tex_FormatDependency_pdf = 'pdf' > > let g:Tex_MultipleCompileFormats = 'dvi,ps,pdf' > > let g:Tex_DefaultTargetFormat = 'pdf' > "let g:Tex_DefaultTargetFormat = 'ps' > > So before switching from a German to an English project a toggle the > comments for the Tex_DefaultTargetFormat and the Tex_BibtexFlavor (and > the spell checking options). Since this is quite inconvenient I thought > about defining two function which do the job. I added > > :function German() > : :set spell spelllang=de_20 > : :let g:Tex_DefaultTargetFormat = 'pdf' > : :let g:Tex_BibtexFlavor = 'biber' > :endfunction > autocmd FileType tex :command! German :cal German() > > :function English() > : :set spell spelllang=en_gb > : :let g:Tex_DefaultTargetFormat = 'ps' > : :let g:Tex_BibtexFlavor = 'bibtex' > :endfunction > autocmd FileType tex :command! English :cal English() > > to my .vimrc. When I am calling the function English the spell checking > and the bibliography settings are changed correctly. Even the default > format is changed (checked by calling :TTarget) but it is not working as > expected. After calling \ll a pdf file is still build, instead of a ps > file. Sometimes (until now I could find out under which circumstance) a > dvi is build, but not a ps like it should. > > Any ideas what is wrong with my function definition? What do I have to > do in order to correctly change the default target from a function. Any > hint is appreciated. > > Thanks and best regards. > > Andreas > > > > -- > > > ------------------------------------------------------------------------------ > Flow-based real-time traffic analytics software. Cisco certified tool. > Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer > Customize your own dashboards, set traffic alerts and generate reports. > Network behavioral analysis & security monitoring. All-in-one tool. > > http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk > _______________________________________________ > Vim-latex-devel mailing list > Vim...@li... > https://lists.sourceforge.net/lists/listinfo/vim-latex-devel > |
From: Andreas G. <and...@tu...> - 2014-02-26 12:10:52
|
Dear Francesco, Thanks for the hint. Following your instructions I set the pdf/biber options in my .vimrc and placed the alternative options in the corresponding *.latexmain file. I first run for the ps/bibtex project ended up with a dvi only. After deleting all latex-related files another run correctly produced the ps. So your solutions seems to work. Thanks a lot. Nevertheless, if somebody has an idea why the call of the appropriate function is not working as expected please let me know. Best regards. Andreas Am 02/26/2014 11:24 AM, schrieb Francesco Montesano: > Hi Andreas, > > This might work: > > Put your default settings (e.g. English) in your .vimrc (or > ftplugin/tex) file. > In the directory where you want you use the other language (e.g. German) > create a > main.tex.latexmain file [1] (I'm assuming that the main latex file is > main.tex). > Then put in main.tex.latexmain: > set spell spelllang=de_20 > let g:Tex_DefaultTargetFormat = 'pdf' > let g:Tex_BibtexFlavor = 'biber' > > This file is loaded after all the .vimrc and .vim/* files. > > I've used successfully this trick to compile with pdflatex specific > projects, while keeping standard latex as default. > > Cheers, > > Fra > > ref: > [1] > http://vim-latex.sourceforge.net/documentation/latex-suite/latex-project.html > > ps: you might think about changing the spelllang only in the current > buffer, in particular if you open different filetypes in the same session > > > > 2014-02-26 11:09 GMT+01:00 Andreas Groh <and...@tu... > <mailto:and...@tu...>>: > > Hi @ all, > > I am using vim latex suite for a while an I am quite happy with how it > is working. I often have to switch between tex-projects in German (using > pdflatex with biber) and project in English (using latex with bibtex). > Hence, up to now I have to change the settings in my .vimrc before I > start working on another project. These are my settings: > > "vim-latex plugin settings > set grepprg=grep\ -nH\ $* > let g:tex_flavor = 'latex' > let g:Tex_BibtexFlavor = 'biber' " use biber instead of bibtex > "let g:Tex_BibtexFlavor = 'bibtex' " using bibtex > let g:Tex_UseMakefile = 0 > let g:Tex_ShowErrorContext = 0 > let g:Tex_AutoFolding = 0 > > let g:Tex_CompileRule_dvi = 'latex --interaction=nonstopmode $*' > let g:Tex_CompileRule_ps = 'dvips -o $*.ps $*.dvi' > let g:Tex_CompileRule_pdf = 'pdflatex --interaction=nonstopmode $*' > > let g:Tex_FormatDependency_ps = 'dvi,ps' > let g:Tex_FormatDependency_pdf = 'pdf' > > let g:Tex_MultipleCompileFormats = 'dvi,ps,pdf' > > let g:Tex_DefaultTargetFormat = 'pdf' > "let g:Tex_DefaultTargetFormat = 'ps' > > So before switching from a German to an English project a toggle the > comments for the Tex_DefaultTargetFormat and the Tex_BibtexFlavor (and > the spell checking options). Since this is quite inconvenient I thought > about defining two function which do the job. I added > > :function German() > : :set spell spelllang=de_20 > : :let g:Tex_DefaultTargetFormat = 'pdf' > : :let g:Tex_BibtexFlavor = 'biber' > :endfunction > autocmd FileType tex :command! German :cal German() > > :function English() > : :set spell spelllang=en_gb > : :let g:Tex_DefaultTargetFormat = 'ps' > : :let g:Tex_BibtexFlavor = 'bibtex' > :endfunction > autocmd FileType tex :command! English :cal English() > > to my .vimrc. When I am calling the function English the spell checking > and the bibliography settings are changed correctly. Even the default > format is changed (checked by calling :TTarget) but it is not working as > expected. After calling \ll a pdf file is still build, instead of a ps > file. Sometimes (until now I could find out under which circumstance) a > dvi is build, but not a ps like it should. > > Any ideas what is wrong with my function definition? What do I have to > do in order to correctly change the default target from a function. Any > hint is appreciated. > > Thanks and best regards. > > Andreas > > > > -- > > ------------------------------------------------------------------------------ > Flow-based real-time traffic analytics software. Cisco certified tool. > Monitor traffic, SLAs, QoS, Medianet, WAAS etc. with NetFlow Analyzer > Customize your own dashboards, set traffic alerts and generate reports. > Network behavioral analysis & security monitoring. All-in-one tool. > http://pubads.g.doubleclick.net/gampad/clk?id=126839071&iu=/4140/ostg.clktrk > _______________________________________________ > Vim-latex-devel mailing list > Vim...@li... > <mailto:Vim...@li...> > https://lists.sourceforge.net/lists/listinfo/vim-latex-devel > > -- ------------------------------------------------------------------------ Andreas Groh phone : +49-351-463.34974 Institut fuer Planetare Geodaesie fax : +49-351-463.37063 Technische Universitaet Dresden email : and...@tu... D-01062 Dresden, Germany web : tpg.geo.tu-dresden.de ------------------------------------------------------------------------ |
From: Andreas G. <and...@tu...> - 2014-02-27 11:40:24
|
Hi everybody, Thanks to the comment from another user I have complemented my functions by the following function calls: call Tex_SetTeXCompilerTarget('Compile',g:Tex_DefaultTargetFormat) call Tex_SetTeXCompilerTarget('View',g:Tex_DefaultTargetFormat) Now everything works as expected. Thanks and best regards. Andreas Am 02/26/2014 11:09 AM, schrieb Andreas Groh: > Hi @ all, > > I am using vim latex suite for a while an I am quite happy with how it > is working. I often have to switch between tex-projects in German (using > pdflatex with biber) and project in English (using latex with bibtex). > Hence, up to now I have to change the settings in my .vimrc before I > start working on another project. These are my settings: > > "vim-latex plugin settings > set grepprg=grep\ -nH\ $* > let g:tex_flavor = 'latex' > let g:Tex_BibtexFlavor = 'biber' " use biber instead of bibtex > "let g:Tex_BibtexFlavor = 'bibtex' " using bibtex > let g:Tex_UseMakefile = 0 > let g:Tex_ShowErrorContext = 0 > let g:Tex_AutoFolding = 0 > > let g:Tex_CompileRule_dvi = 'latex --interaction=nonstopmode $*' > let g:Tex_CompileRule_ps = 'dvips -o $*.ps $*.dvi' > let g:Tex_CompileRule_pdf = 'pdflatex --interaction=nonstopmode $*' > > let g:Tex_FormatDependency_ps = 'dvi,ps' > let g:Tex_FormatDependency_pdf = 'pdf' > > let g:Tex_MultipleCompileFormats = 'dvi,ps,pdf' > > let g:Tex_DefaultTargetFormat = 'pdf' > "let g:Tex_DefaultTargetFormat = 'ps' > > So before switching from a German to an English project a toggle the > comments for the Tex_DefaultTargetFormat and the Tex_BibtexFlavor (and > the spell checking options). Since this is quite inconvenient I thought > about defining two function which do the job. I added > > :function German() > : :set spell spelllang=de_20 > : :let g:Tex_DefaultTargetFormat = 'pdf' > : :let g:Tex_BibtexFlavor = 'biber' > :endfunction > autocmd FileType tex :command! German :cal German() > > :function English() > : :set spell spelllang=en_gb > : :let g:Tex_DefaultTargetFormat = 'ps' > : :let g:Tex_BibtexFlavor = 'bibtex' > :endfunction > autocmd FileType tex :command! English :cal English() > > to my .vimrc. When I am calling the function English the spell checking > and the bibliography settings are changed correctly. Even the default > format is changed (checked by calling :TTarget) but it is not working as > expected. After calling \ll a pdf file is still build, instead of a ps > file. Sometimes (until now I could find out under which circumstance) a > dvi is build, but not a ps like it should. > > Any ideas what is wrong with my function definition? What do I have to > do in order to correctly change the default target from a function. Any > hint is appreciated. > > Thanks and best regards. > > Andreas > > > -- ------------------------------------------------------------------------ Andreas Groh phone : +49-351-463.34974 Institut fuer Planetare Geodaesie fax : +49-351-463.37063 Technische Universitaet Dresden email : and...@tu... D-01062 Dresden, Germany web : tpg.geo.tu-dresden.de ------------------------------------------------------------------------ |