latex linux windows,科学网—Win,Linux系统Vim latex suite配置 - 储著飞的博文

折腾了一天终于把Win和Ubuntu下的Vim latex suite搞定了,接下来将安装的细节记录下来:

http://blog.csdn.net/guanggy/archive/2009/11/09/4790111.aspx

这个网址给出了详细的设置过程。

接下里根据网络内容,做点补充:

在_vimrc中写上let g:Imap_UsePlaceHolders=0,能避免其自动插入place holder

在~ftpluginlatex suitetexrc中142行

if has('win32')

TexLet g:Tex_ViewRule_ps = 'gsview32'

TexLet g:Tex_ViewRule_pdf = 'Foxit Phantom.exe'

TexLet g:Tex_ViewRule_dvi = 'yap -1'

设置默认的pdf软件,需首先右击我的电脑-属性-高级中设置$PATH变量,将路径加进去。比如C:Program FilesPhantom,然后写入'Foxit Phantom.exe‘即可。或直接设置 TexLet g:Tex_ViewRule_pdf = 'C:Program FilesPhantomFoxit Phantom.exe'

另外,结合各种网络资源,我的_vimrc如下:

" Platform

function! MySys()

if has("win32")

return "windows"

else

return "linux"

endif

endfunction

" REQUIRED. This makes vim invoke Latex-Suite when you open a tex file.

filetype plugin on

" IMPORTANT: win32 users will need to have 'shellslash' set so that latex

" can be called correctly.

set shellslash

" IMPORTANT: grep will sometimes skip displaying the file name if you

" search in a singe file. This will confuse Latex-Suite. Set your grep

" program to always generate a file-name.

set grepprg=grep -nH $*

" OPTIONAL: This enables automatic indentation as you type.

filetype indent on

" OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to

" 'plaintex' instead of 'tex', which results in vim-latex not being loaded.

" The following changes the default filetype back to 'tex':

let g:tex_flavor='tex'

let g:Imap_UsePlaceHolders = 0

set fileencodings=ucs-bom,utf-8,cp936,gb18030,big5,euc-jp,euc-kr,latin1

set guifont=NSimSun:h14:cGB2312

colorscheme koehler

set nocompatible

source $VIMRUNTIME/vimrc_example.vim

set number

set autoindent

set nobackup

set showmatch

set formatoptions+=mM

set fileencodings=ucs-bom,utf-8,gbk

function! SwitchToBuf(filename)

"let fullfn = substitute(a:filename, "^\~/", $HOME . "/", "")

" find in current tab

let bufwinnr = bufwinnr(a:filename)

if bufwinnr != -1

exec bufwinnr . "wincmd w"

return

else

" find in each tab

tabfirst

let tab = 1

while tab <= tabpagenr("$")

let bufwinnr = bufwinnr(a:filename)

if bufwinnr != -1

exec "normal " . tab . "gt"

exec bufwinnr . "wincmd w"

return

endif

tabnext

let tab = tab + 1

endwhile

" not exist, new tab

exec "tabnew " . a:filename

endif

endfunction

noremap         gj

noremap         gk

noremap        gj

noremap          gk

inoremap gj

inoremap    gk

" Key mappings for quick arithmetic inside Vim

nnoremap ma yypV:!calcu '"'k$

vnoremap ma yopV:!calcu '"'k$

nnoremap mr yyV:!calcu '"'$

vnoremap mr ygvmaomb:r !calcu '"'"ay$dd`bv`a"ap

" Key mapping to stop the search highlight

nmap       :nohlsearch

imap :nohlsearch

" Key mapping for the taglist.vim plugin

nmap       :Tlist

imap :Tlist

" Key mappings for the quickfix commands

nmap :cn

nmap :cp

" Non-GUI setting

if !has('gui_running')

" Do not increase the windows width in the taglist.vim plugin

if has('eval')

let Tlist_Inc_Winwidth=0

endif

" Set text-mode menu

if has('wildmenu')

set wildmenu

set cpoptions-=<

set wildcharm=

nmap       :emenu

imap :emenu

endif

endif

if has('autocmd')

autocmd BufNewFile *.tex so $VIMvimfilesftpluginlatex-suitemain.vim

function! SetFileEncodings(encodings)

let b:my_fileencodings_bak=&fileencodings

let &fileencodings=a:encodings

endfunction

function! RestoreFileEncodings()

let &fileencodings=b:my_fileencodings_bak

unlet b:my_fileencodings_bak

endfunction

function! CheckFileEncoding()

if &modified && &fileencoding != ''

exec 'e! ++enc=' . &fileencoding

endif

endfunction

function! ConvertHtmlEncoding(encoding)

if a:encoding ==? 'gb2312'

return 'gbk'              " GB2312 imprecisely means GBK in HTML

elseif a:encoding ==? 'iso-8859-1'

return 'latin1'           " The canonical encoding name in Vim

elseif a:encoding ==? 'utf8'

return 'utf-8'            " Other encoding aliases should follow here

else

return a:encoding

endif

endfunction

function! DetectHtmlEncoding()

if &filetype != 'html'

return

endif

normal m`

normal gg

if search('c') != 0

let reg_bak=@"

normal y$

let charset=matchstr(@", 'text/html; charset=zs[-A-Za-z0-9_]+')

let charset=ConvertHtmlEncoding(charset)

normal ``

let @"=reg_bak

if &fileencodings == ''

let auto_encodings=',' . &encoding . ','

else

let auto_encodings=',' . &fileencodings . ','

endif

if charset !=? &fileencoding &&

(auto_encodings =~ ',' . &fileencoding . ',' || &fileencoding == '')

silent! exec 'e ++enc=' . charset

endif

else

normal ``

endif

endfunction

function! GnuIndent()

setlocal cinoptions=>4,n-2,{2,^-2,:2,=2,g0,h2,p5,t0,+2,(0,u0,w1,m1

setlocal shiftwidth=2

setlocal tabstop=8

endfunction

function! RemoveTrailingSpace()

if $VIM_HATE_SPACE_ERRORS != '0' &&

(&filetype == 'c' || &filetype == 'cpp' || &filetype == 'vim')

normal m`

silent! :%s/s+$//e

normal ``

endif

endfunction

" Highlight space errors in C/C++ source files (Vim tip #935)

if $VIM_HATE_SPACE_ERRORS != '0'

let c_space_errors=1

endif

" Use Canadian spelling convention in engspchk (Vim script #195)

let spchkdialect='can'

" Show syntax highlighting attributes of character under cursor (Vim

" script #383)

map a :call SyntaxAttr()

" Automatically find scripts in the autoload directory

au FuncUndefined * exec 'runtime autoload/' . expand('') . '.vim'

" File type related autosetting

au FileType c,cpp setlocal cinoptions=:0,g0,(0,w1 shiftwidth=4 tabstop=4

au FileType diff  setlocal shiftwidth=4 tabstop=4

au FileType html  setlocal autoindent indentexpr=

au FileType changelog setlocal textwidth=76

" Text file encoding autodetection

au BufReadPre  *.gb               call SetFileEncodings('gbk')

au BufReadPre  *.big5             call SetFileEncodings('big5')

au BufReadPre  *.nfo              call SetFileEncodings('cp437')

au BufReadPost *.gb,*.big5,*.nfo  call RestoreFileEncodings()

au BufWinEnter *.txt              call CheckFileEncoding()

" Detect charset encoding in an HTML file

au BufReadPost *.htm* nested      call DetectHtmlEncoding()

" Recognize standard C++ headers

au BufEnter /usr/include/c++/*    setf cpp

au BufEnter /usr/include/g++-3/*  setf cpp

" Setting for files following the GNU coding standard

au BufEnter /usr/*                call GnuIndent()

" Remove trailing spaces for C/C++ and Vim files

au BufWritePre *                  call RemoveTrailingSpace()

endif

"Fast edit vimrc

if MySys() == 'linux'

"Fast reloading of the .vimrc

map ss :source ~/.vimrc

"Fast editing of .vimrc

map ee :call SwitchToBuf("~/.vimrc")

"When .vimrc is edited, reload it

autocmd! bufwritepost .vimrc source ~/.vimrc

elseif MySys() == 'windows'

" Set helplang

set helplang=cn

"Fast reloading of the _vimrc

map ss :source ~/_vimrc

"Fast editing of _vimrc

map ee :call SwitchToBuf("~/_vimrc")

"When _vimrc is edited, reload it

autocmd! bufwritepost _vimrc source ~/_vimrc

endif

" For windows version

if MySys() == 'windows'

source $VIMRUNTIME/mswin.vim

behave mswin

endif

转载本文请联系原作者获取授权,同时请注明本文来自储著飞科学网博客。

链接地址:http://blog.sciencenet.cn/blog-448160-381991.html

上一篇:英语基本语法

下一篇:Ubuntu为旧版本软件建立软链接

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值