(G)vim+Latexsuite 安装和配置
时间:2010-08-17 来源:zhiyizhi
部分内容参照:http://vim-latex.sourceforge.net/documentation/latex-suite-quickstart.html
http://hi.baidu.com/pkucbj/blog/item/6e859e3de24c1ae93c6d9707.html,在此表示感激!
测试环境:Debian Squeeze+TeXLive2009, VIM - Vi IMproved 7.2
1. sudo apt-get install vim-gnome
2. $ mkdir ~/.vim
然后下载latexSuite20060325.tar.gz(或者到http://vim-latex.sourceforge.net/下载,比如说vim-latex-1.8.23-20100129-r1104.tar.gz),并解压到该目录
$ tar zxvf latexSuite20060325.tar.gz && mv latexSuite20060325/* .vim/
3. 建立配置文件~/.vimrc和~/.gvimrc,内容为如下:
这里是.vimrc的内容:
" .vimrc 文件从这里开始
"项目: gvim 配置文件
"作者: yonsan
"安装: sudo apt-get install vim-gtk
"用法: 将本文件(.vimrc)拷贝到$HOME/
"设置自动换行
set wrap
"用 murphy 调色板
colo murphy
"设置用于GUI图形用户界面的字体列表。
" set guifont=SimSun\ 10
" set nocompatible
"设定文件浏览器目录为当前目录
set bsdir=buffer
set autochdir
"设置编码
set enc=utf-8
"设置文件编码
set fenc=utf-8
"设置文件编码检测类型及支持格式
set fencs=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
"指定菜单语言
set langmenu=zh_CN.UTF-8
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
"设置语法高亮度
"set syn=cpp
if &t_Co > 1
syntax enable
endif
"显示行号
set nu!
"查找结果高亮度显示
set hlsearch
"tab宽度
set tabstop=4
"set cindent shiftwidth=4
"set autoindent shiftwidth=4
"C/C++注释
"set comments=://
"修正自动C式样注释功能 <2005/07/16>
"set comments=s1:/*,mb:*,ex0:/
"增强检索功能
"set tags=./tags,./../tags,./**/tags
"保存文件格式
set fileformats=unix,dos
"键盘操作
"map <Up> gk
"map <Down> gj
"命令行高度
set cmdheight=1
"中文帮助
if version > 603
set helplang=cn
endi
"为了latex-suite
"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 alway generate a file-name.
set grepprg=grep\ -nH\ $*
"EOF .vimrc 的尾
" 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='latex'
"Set mapleader
let mapleader = ""
".vimrc文件在这里结束
#################################################
这里是.gvimrc的内容:
" .gvimrc 从这里开始
"项目: gvim 配置文件
"作者: yonsan
"安装: sudo apt-get install vim-gtk
"用法: 将本文件(.vimrc)拷贝到$HOME/
"修改: Tiao Lu
"用 murphy 调色板
"colo murphy
"设置用于GUI图形用户界面的字体列表。
" set guifont=SimSun\ 10
" set nocompatible
"设定文件浏览器目录为当前目录
set bsdir=buffer
set autochdir
"设置编码
set enc=utf-8
"设置文件编码
set fenc=utf-8
"设置文件编码检测类型及支持格式
set fencs=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
"指定菜单语言
set langmenu=zh_CN.UTF-8
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
"设置语法高亮度
"set syn=cpp
if &t_Co > 1
syntax enable
endif
"显示行号
set nu!
"查找结果高亮度显示
set hlsearch
"tab宽度
set tabstop=4
"set cindent shiftwidth=4
"set autoindent shiftwidth=4
"C/C++注释
"set comments=://
"修正自动C式样注释功能 <2005/07/16>
"set comments=s1:/*,mb:*,ex0:/
"增强检索功能
"set tags=./tags,./../tags,./**/tags
"保存文件格式
set fileformats=unix,dos
"键盘操作
"map <Up> gk
"map <Down> gj
"命令行高度
set cmdheight=1
"中文帮助
if version > 603
set helplang=cn
endi
" =============================================================================
" PART 1 : FOR GVIM
" =============================================================================
" {{{ Syntax highlighiting settings
" -----------------------------------------------------------------------------
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
" -----------------------------------------------------------------------------
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
" }}}
" {{{ color settings
if &t_Co > 2 || has("gui_running")
" -----------------------------------------------------------------------------
" This color scheme uses a dark grey background.
" This theme, based on evening (with some input from Torte) is designed to
" seperate active text (code) from background/line numbers/folds/listchars by
" having different background colors on the non-code and the code (just
" slightly). If you look at the screenshot below, you will get the idea.
" All non-code(include indents) and string literals have a black background
" while code has a very dark grey background.
" -----------------------------------------------------------------------------
set background=dark
hi clear
if exists("syntax_on")
syntax reset
endif
"let colors_name = "yonsan"
" -----------------------------------------------------------------------------
" Primary (hyper/selected/colored background)
" -----------------------------------------------------------------------------
" Search
hi IncSearch guibg=black guifg=cyan
hi Search guibg=black guifg=cyan
" Visual
hi Visual guibg=black guifg=yellow
hi VisualNOS guibg=black guifg=yellow gui=underline
" Borders
hi StatusLine guibg=black guifg=white
hi StatusLineNC guibg=grey22 guifg=grey45
hi VertSplit guibg=black guifg=grey45
" Cursors
hi Cursor guibg=white guifg=black
hi lCursor guibg=white guifg=black
" Diff
hi DiffText guibg=red guifg=white gui=bold
hi DiffAdd guibg=darkblue guifg=white
hi DiffChange guibg=darkmagenta guifg=white
hi DiffDelete guibg=darkcyan guifg=blue gui=bold
" Misc
hi Title guifg=magenta gui=bold
hi Question guibg=black guifg=green gui=bold
hi Todo guibg=black guifg=cyan
hi Error guibg=red guifg=white
hi WildMenu guibg=cyan guifg=black
" -----------------------------------------------------------------------------
" Primary (active/code/text/grey background)
" -----------------------------------------------------------------------------
" Normal
hi Normal guibg=grey22 guifg=white
" Constants
hi Constant guibg=grey22 guifg=#ffa0a0
hi String guibg=grey22 guifg=#ffa0a0
hi Character guibg=grey22 guifg=#ffa0a0
hi Number guibg=grey22 guifg=#ffa0a0
hi Boolean guibg=grey22 guifg=#ffa0a0
hi Float guibg=grey22 guifg=#ffa0a0
" Identifier
hi Identifier guibg=grey22 guifg=#40ffff
hi Function guibg=grey22 guifg=#40ffff
" Statement
hi Statement guibg=grey22 guifg=#ffff60
hi Conditional guibg=grey22 guifg=#ffff60
hi Repeat guibg=grey22 guifg=#ffff60
hi Label guibg=grey22 guifg=#ffff60
hi Operator guibg=grey22 guifg=#ffff60
hi Keyword guibg=grey22 guifg=#ffff60
hi Exception guibg=grey22 guifg=#ffff60
" PreProc
hi PreProc guibg=grey22 guifg=#ff80ff
hi Include guibg=grey22 guifg=#ff80ff
hi Define guibg=grey22 guifg=#ff80ff
hi Macro guibg=grey22 guifg=#ff80ff
hi PreCondit guibg=grey22 guifg=#ff80ff
" Type
hi Type guibg=grey22 guifg=#60ff60
hi StorageClass guibg=grey22 guifg=#60ff60
hi Structure guibg=grey22 guifg=#60ff60
hi Typedef guibg=grey22 guifg=#60ff60
" Special
hi Special guibg=grey22 guifg=orange
hi SpecialChar guibg=grey22 guifg=orange
hi Tag guibg=grey22 guifg=orange
hi Delimiter guibg=grey22 guifg=orange
hi Debug guibg=grey22 guifg=orange
" Misc
hi Underlined guibg=grey22 guifg=#ffff60 gui=underline
" -----------------------------------------------------------------------------
" Secondary (inactive/black background)
" -----------------------------------------------------------------------------
" Comments
hi Comment guibg=black guifg=#80a0ff
hi SpecialComment guibg=black guifg=#80a0ff gui=underline
" Messages
hi ModeMsg guibg=black guifg=white gui=bold
hi MoreMsg guibg=black guifg=seagreen gui=bold
hi WarningMsg guibg=black guifg=blue gui=bold
hi ErrorMsg guibg=black guifg=red gui=bold
" Folding
hi Folded guibg=black guifg=grey45
hi FoldColumn guibg=black guifg=grey45
" Misc
hi Ignore guibg=black guifg=grey45
hi NonText guibg=black guifg=grey45
hi LineNr guibg=black guifg=grey45
hi SpecialKey guibg=black guifg=grey45
hi SignColumn guibg=black guifg=grey45
hi Directory guibg=black guifg=cyan
endif
" }}}
if &t_Co > 2 || has("gui_running")
set columns=120 lines=40 " don't inherit geometry from parent term
set mousemodel=popup " right mouse button pops up a menu in the GUI
set backspace=2 " make backspace work normal
set whichwrap+=<,>,h,l " backspace and cursor keys wrap to
set mouse=a " use mouse everywhere
set matchtime=5 " 1/10 second to show the matching paren
set listchars=tab:\|\ ,trail:.,extends:>,precedes:<,eol:$ " what to show when :set list
set scrolloff=10 " minimal number of screen lines to keep above and below the cursor
set novisualbell " use visual bell instead of beeping
" For bug 33327, add a mapping which allows shift-insert to function
" as expected in insert and command-line modes
map! <s-insert> <c-r>*
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
if filereadable("/etc/vim/gvimrc.local")
source /etc/vim/gvimrc.local
endif
endif
""=============================================================================
" PART 2 : FOR VIM
" =============================================================================
"
" {{{ General settings
" -----------------------------------------------------------------------------
" The following are some sensible defaults for Vim for most users.
" We attempt to change as little as possible from Vim's defaults,
" deviating only where it makes sense
" -----------------------------------------------------------------------------
set nocompatible " Use Vim defaults (much better!)
set bs=2 " Allow backspacing over everything in insert mode
set ai " Always set auto-indenting on
set history=1000 " keep 50 lines of command history
set ruler " Show the cursor position all the time
set nu! " Show number on left
set viminfo='20,\"500 " Keep a .viminfo file.
" Don't use Ex mode, use Q for formatting
map Q gq
" When doing tab completion, give the following files lower priority. You may
" wish to set 'wildignore' to completely ignore files, and 'wildmenu' to enable
" enhanced tab completion. These can be done in the user vimrc file.
set suffixes+=.info,.aux,.log,.dvi,.bbl,.out,.nav,.toc,.snm
" When displaying line numbers, don't use an annoyingly wide number column. This
" doesn't enable line numbers -- :set number will do that. The value given is a
" minimum width to use for the number column, not a fixed size.
if v:version >= 700
set numberwidth=3
endif
" }}}
" {{{ Modeline isettings
" -----------------------------------------------------------------------------
" We don't allow modelines by default. See bug #14088 and bug #73715.
" If you're not concerned about these, you can enable them on a per-user
" basis by adding "set modeline" to your ~/.vimrc file.
" -----------------------------------------------------------------------------
set nomodeline
" }}}
" {{{ Locale settingsi
" -----------------------------------------------------------------------------
" Try to come up with some nice sane GUI fonts. Also try to set a sensible
" value for fileencodings based upon locale. These can all be overridden in
" the user vimrc file.
" -----------------------------------------------------------------------------
" {{{ Filetype iplugin settings
" -----------------------------------------------------------------------------
" Enable plugin-provided filetype settings, but only if the ftplugin
" directory exists (which it won't on livecds, for example).
" -----------------------------------------------------------------------------
if isdirectory(expand("$VIMRUNTIME/ftplugin"))
filetype plugin on
" Uncomment the next line (or copy to your ~/.vimrc) for plugin-provided
" indent settings. Some people don't like these, so we won't turn them on by
" default.
" filetype indent on
endif
" }}}
" {{{ Fix &shell, see biug #101665.
if "" == &shell
if executable("/bin/bash")
set shell=/bin/bash
elseif executable("/bin/sh")
set shell=/bin/sh
endif
endif
"}}}
if &t_Co > 2 || has("gui_running")
set laststatus=2 " always show the status line
set statusline=%<%f%h%m%r%=%{&ff}\ %l,%c%V\ \ \tab\:%{ShowTab()}\ %P
fu ShowTab()
return (indent('.') / &ts )
endf
set linespace=1 " space it out a little more (easier to read)
set wildmenu " turn on wild menu, try typing :h and press <Tab>
set ai " autoindent
set si " smartindent
set fo=tcrqn " see help (complex)
set cindent " do C-style indenting
set tabstop=4 " tab spacing (settings below are just to unify it)
set softtabstop=4 " unify
set shiftwidth=4 " unify
set noexpandtab " real tabs please!
set smarttab " use tabs at the start of a line, spaces elsewhere
set nowrap " do not wrap lines
" Use a sufficiently wide window automatically when started as "gvimdiff"
if (&foldmethod == 'diff')
set columns=165
endif
endif
" {{{ Our default /bin/ish is bash, not ksh, so syntax highlighting for .sh
" files should default to bash. See :help sh-syntax and bug #101819.
if has("eval")
let is_bash=1
endif
" }}}
" {{{ Autocommandsi
if has("autocmd")
endif " has("autocmd")
" }}}
" 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='latex'
"EOF .gvimrc 在这里结束
#############################################
4. 建立~/.vim/ftplugin/tex.vim,内容为:
" this is mostly a matter of taste. but LaTeX looks good with just a bit
" of indentation.
set sw=2
" TIP: if you write your \label's as \label{fig:something}, then if you
" type in \ref{fig: and press <C-n> you will automatically cycle through
" all the figure labels. Very useful!
set iskeyword+=:
######################################################
5.反向搜索设置(dvi->source):
建立目录~/.vim/ftpplugin/tex,然后在~/.vim/ftplugin/tex/texrc 中找到如下代码【打开时可能要求选择适当的编码】:(如果没有这个文件,把~/.vim/ftplugin/latex-suite/texrc copy 过来)
" the option below specifies an editor for the dvi viewer while starting
" up the dvi viewer according to Dimitri Antoniou's tip on vim.sf.net (tip
" #225)
TexLet g:Tex_UseEditorSettingInDVIViewer = 0
把值设为1。如下:
TexLet g:Tex_UseEditorSettingInDVIViewer = 1
同时把dvi 编译选项设为
TexLet g:Tex_CompileRule_dvi = 'latex -src-specials -interaction=nonstopmode $*'
然后找到
if executable('xdg-open')
TexLet g:Tex_ViewRule_ps =
把紧接着的三行改为:
if executable('xdg-open')
TexLet g:Tex_ViewRule_ps = 'okular -unique'
TexLet g:Tex_ViewRule_pdf = 'okular -unique'
TexLet g:Tex_ViewRule_dvi = 'okular -unique'
再打开Okuar,把Editor设置为
gvim -c ":RemoteOpen +%l %f"
以后使用Shift+鼠标左键就可以实现inverse search了。
注意:到目前为止,还没有办法实现pdf和source之间的正反向搜索。不过编辑器Texworks可以实现。
6. 安装帮助文档
启动gvim,然后在标准模式输入
:helptags ~/.vim/doc
7. 以后你可以使用:help latex-suite.txt获得帮助
现在你就可以使用gvim file.tex进行编辑了
8. 为gvim添加启动项
其中Launcher Properties如下:
Type Application
Name GVIM
Command /usr/bin/gvim
Comment GVIM 4 LaTeX
icon /usr/share/pixmaps/vim.svg
9. 实现标签页功能
实际应用中,可使用 Shell 提供的别名功能,对 “gvim --remote-tab-silent” 这样的长命令行进行友好简化,做法是编辑 $HOME/.bashrc 文件,向其中添加:
#给gvim别名实现自动打开标签页
alias gvim='gvim --remote-tab-silent'
然后修改/usr/share/applications/gvim.desktop中的
#Exec=gvim -f %F
Exec=gvim
10. 添加Launcher bar
按照前面提到的方法添加/usr/share/applications/gvim.desktop就可以了
http://hi.baidu.com/pkucbj/blog/item/6e859e3de24c1ae93c6d9707.html,在此表示感激!
测试环境:Debian Squeeze+TeXLive2009, VIM - Vi IMproved 7.2
1. sudo apt-get install vim-gnome
2. $ mkdir ~/.vim
然后下载latexSuite20060325.tar.gz(或者到http://vim-latex.sourceforge.net/下载,比如说vim-latex-1.8.23-20100129-r1104.tar.gz),并解压到该目录
$ tar zxvf latexSuite20060325.tar.gz && mv latexSuite20060325/* .vim/
3. 建立配置文件~/.vimrc和~/.gvimrc,内容为如下:
这里是.vimrc的内容:
" .vimrc 文件从这里开始
"项目: gvim 配置文件
"作者: yonsan
"安装: sudo apt-get install vim-gtk
"用法: 将本文件(.vimrc)拷贝到$HOME/
"设置自动换行
set wrap
"用 murphy 调色板
colo murphy
"设置用于GUI图形用户界面的字体列表。
" set guifont=SimSun\ 10
" set nocompatible
"设定文件浏览器目录为当前目录
set bsdir=buffer
set autochdir
"设置编码
set enc=utf-8
"设置文件编码
set fenc=utf-8
"设置文件编码检测类型及支持格式
set fencs=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
"指定菜单语言
set langmenu=zh_CN.UTF-8
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
"设置语法高亮度
"set syn=cpp
if &t_Co > 1
syntax enable
endif
"显示行号
set nu!
"查找结果高亮度显示
set hlsearch
"tab宽度
set tabstop=4
"set cindent shiftwidth=4
"set autoindent shiftwidth=4
"C/C++注释
"set comments=://
"修正自动C式样注释功能 <2005/07/16>
"set comments=s1:/*,mb:*,ex0:/
"增强检索功能
"set tags=./tags,./../tags,./**/tags
"保存文件格式
set fileformats=unix,dos
"键盘操作
"map <Up> gk
"map <Down> gj
"命令行高度
set cmdheight=1
"中文帮助
if version > 603
set helplang=cn
endi
"为了latex-suite
"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 alway generate a file-name.
set grepprg=grep\ -nH\ $*
"EOF .vimrc 的尾
" 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='latex'
"Set mapleader
let mapleader = ""
".vimrc文件在这里结束
#################################################
这里是.gvimrc的内容:
" .gvimrc 从这里开始
"项目: gvim 配置文件
"作者: yonsan
"安装: sudo apt-get install vim-gtk
"用法: 将本文件(.vimrc)拷贝到$HOME/
"修改: Tiao Lu
"用 murphy 调色板
"colo murphy
"设置用于GUI图形用户界面的字体列表。
" set guifont=SimSun\ 10
" set nocompatible
"设定文件浏览器目录为当前目录
set bsdir=buffer
set autochdir
"设置编码
set enc=utf-8
"设置文件编码
set fenc=utf-8
"设置文件编码检测类型及支持格式
set fencs=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
"指定菜单语言
set langmenu=zh_CN.UTF-8
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
"设置语法高亮度
"set syn=cpp
if &t_Co > 1
syntax enable
endif
"显示行号
set nu!
"查找结果高亮度显示
set hlsearch
"tab宽度
set tabstop=4
"set cindent shiftwidth=4
"set autoindent shiftwidth=4
"C/C++注释
"set comments=://
"修正自动C式样注释功能 <2005/07/16>
"set comments=s1:/*,mb:*,ex0:/
"增强检索功能
"set tags=./tags,./../tags,./**/tags
"保存文件格式
set fileformats=unix,dos
"键盘操作
"map <Up> gk
"map <Down> gj
"命令行高度
set cmdheight=1
"中文帮助
if version > 603
set helplang=cn
endi
" =============================================================================
" PART 1 : FOR GVIM
" =============================================================================
" {{{ Syntax highlighiting settings
" -----------------------------------------------------------------------------
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
" -----------------------------------------------------------------------------
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
" }}}
" {{{ color settings
if &t_Co > 2 || has("gui_running")
" -----------------------------------------------------------------------------
" This color scheme uses a dark grey background.
" This theme, based on evening (with some input from Torte) is designed to
" seperate active text (code) from background/line numbers/folds/listchars by
" having different background colors on the non-code and the code (just
" slightly). If you look at the screenshot below, you will get the idea.
" All non-code(include indents) and string literals have a black background
" while code has a very dark grey background.
" -----------------------------------------------------------------------------
set background=dark
hi clear
if exists("syntax_on")
syntax reset
endif
"let colors_name = "yonsan"
" -----------------------------------------------------------------------------
" Primary (hyper/selected/colored background)
" -----------------------------------------------------------------------------
" Search
hi IncSearch guibg=black guifg=cyan
hi Search guibg=black guifg=cyan
" Visual
hi Visual guibg=black guifg=yellow
hi VisualNOS guibg=black guifg=yellow gui=underline
" Borders
hi StatusLine guibg=black guifg=white
hi StatusLineNC guibg=grey22 guifg=grey45
hi VertSplit guibg=black guifg=grey45
" Cursors
hi Cursor guibg=white guifg=black
hi lCursor guibg=white guifg=black
" Diff
hi DiffText guibg=red guifg=white gui=bold
hi DiffAdd guibg=darkblue guifg=white
hi DiffChange guibg=darkmagenta guifg=white
hi DiffDelete guibg=darkcyan guifg=blue gui=bold
" Misc
hi Title guifg=magenta gui=bold
hi Question guibg=black guifg=green gui=bold
hi Todo guibg=black guifg=cyan
hi Error guibg=red guifg=white
hi WildMenu guibg=cyan guifg=black
" -----------------------------------------------------------------------------
" Primary (active/code/text/grey background)
" -----------------------------------------------------------------------------
" Normal
hi Normal guibg=grey22 guifg=white
" Constants
hi Constant guibg=grey22 guifg=#ffa0a0
hi String guibg=grey22 guifg=#ffa0a0
hi Character guibg=grey22 guifg=#ffa0a0
hi Number guibg=grey22 guifg=#ffa0a0
hi Boolean guibg=grey22 guifg=#ffa0a0
hi Float guibg=grey22 guifg=#ffa0a0
" Identifier
hi Identifier guibg=grey22 guifg=#40ffff
hi Function guibg=grey22 guifg=#40ffff
" Statement
hi Statement guibg=grey22 guifg=#ffff60
hi Conditional guibg=grey22 guifg=#ffff60
hi Repeat guibg=grey22 guifg=#ffff60
hi Label guibg=grey22 guifg=#ffff60
hi Operator guibg=grey22 guifg=#ffff60
hi Keyword guibg=grey22 guifg=#ffff60
hi Exception guibg=grey22 guifg=#ffff60
" PreProc
hi PreProc guibg=grey22 guifg=#ff80ff
hi Include guibg=grey22 guifg=#ff80ff
hi Define guibg=grey22 guifg=#ff80ff
hi Macro guibg=grey22 guifg=#ff80ff
hi PreCondit guibg=grey22 guifg=#ff80ff
" Type
hi Type guibg=grey22 guifg=#60ff60
hi StorageClass guibg=grey22 guifg=#60ff60
hi Structure guibg=grey22 guifg=#60ff60
hi Typedef guibg=grey22 guifg=#60ff60
" Special
hi Special guibg=grey22 guifg=orange
hi SpecialChar guibg=grey22 guifg=orange
hi Tag guibg=grey22 guifg=orange
hi Delimiter guibg=grey22 guifg=orange
hi Debug guibg=grey22 guifg=orange
" Misc
hi Underlined guibg=grey22 guifg=#ffff60 gui=underline
" -----------------------------------------------------------------------------
" Secondary (inactive/black background)
" -----------------------------------------------------------------------------
" Comments
hi Comment guibg=black guifg=#80a0ff
hi SpecialComment guibg=black guifg=#80a0ff gui=underline
" Messages
hi ModeMsg guibg=black guifg=white gui=bold
hi MoreMsg guibg=black guifg=seagreen gui=bold
hi WarningMsg guibg=black guifg=blue gui=bold
hi ErrorMsg guibg=black guifg=red gui=bold
" Folding
hi Folded guibg=black guifg=grey45
hi FoldColumn guibg=black guifg=grey45
" Misc
hi Ignore guibg=black guifg=grey45
hi NonText guibg=black guifg=grey45
hi LineNr guibg=black guifg=grey45
hi SpecialKey guibg=black guifg=grey45
hi SignColumn guibg=black guifg=grey45
hi Directory guibg=black guifg=cyan
endif
" }}}
if &t_Co > 2 || has("gui_running")
set columns=120 lines=40 " don't inherit geometry from parent term
set mousemodel=popup " right mouse button pops up a menu in the GUI
set backspace=2 " make backspace work normal
set whichwrap+=<,>,h,l " backspace and cursor keys wrap to
set mouse=a " use mouse everywhere
set matchtime=5 " 1/10 second to show the matching paren
set listchars=tab:\|\ ,trail:.,extends:>,precedes:<,eol:$ " what to show when :set list
set scrolloff=10 " minimal number of screen lines to keep above and below the cursor
set novisualbell " use visual bell instead of beeping
" For bug 33327, add a mapping which allows shift-insert to function
" as expected in insert and command-line modes
map! <s-insert> <c-r>*
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
if filereadable("/etc/vim/gvimrc.local")
source /etc/vim/gvimrc.local
endif
endif
""=============================================================================
" PART 2 : FOR VIM
" =============================================================================
"
" {{{ General settings
" -----------------------------------------------------------------------------
" The following are some sensible defaults for Vim for most users.
" We attempt to change as little as possible from Vim's defaults,
" deviating only where it makes sense
" -----------------------------------------------------------------------------
set nocompatible " Use Vim defaults (much better!)
set bs=2 " Allow backspacing over everything in insert mode
set ai " Always set auto-indenting on
set history=1000 " keep 50 lines of command history
set ruler " Show the cursor position all the time
set nu! " Show number on left
set viminfo='20,\"500 " Keep a .viminfo file.
" Don't use Ex mode, use Q for formatting
map Q gq
" When doing tab completion, give the following files lower priority. You may
" wish to set 'wildignore' to completely ignore files, and 'wildmenu' to enable
" enhanced tab completion. These can be done in the user vimrc file.
set suffixes+=.info,.aux,.log,.dvi,.bbl,.out,.nav,.toc,.snm
" When displaying line numbers, don't use an annoyingly wide number column. This
" doesn't enable line numbers -- :set number will do that. The value given is a
" minimum width to use for the number column, not a fixed size.
if v:version >= 700
set numberwidth=3
endif
" }}}
" {{{ Modeline isettings
" -----------------------------------------------------------------------------
" We don't allow modelines by default. See bug #14088 and bug #73715.
" If you're not concerned about these, you can enable them on a per-user
" basis by adding "set modeline" to your ~/.vimrc file.
" -----------------------------------------------------------------------------
set nomodeline
" }}}
" {{{ Locale settingsi
" -----------------------------------------------------------------------------
" Try to come up with some nice sane GUI fonts. Also try to set a sensible
" value for fileencodings based upon locale. These can all be overridden in
" the user vimrc file.
" -----------------------------------------------------------------------------
" {{{ Filetype iplugin settings
" -----------------------------------------------------------------------------
" Enable plugin-provided filetype settings, but only if the ftplugin
" directory exists (which it won't on livecds, for example).
" -----------------------------------------------------------------------------
if isdirectory(expand("$VIMRUNTIME/ftplugin"))
filetype plugin on
" Uncomment the next line (or copy to your ~/.vimrc) for plugin-provided
" indent settings. Some people don't like these, so we won't turn them on by
" default.
" filetype indent on
endif
" }}}
" {{{ Fix &shell, see biug #101665.
if "" == &shell
if executable("/bin/bash")
set shell=/bin/bash
elseif executable("/bin/sh")
set shell=/bin/sh
endif
endif
"}}}
if &t_Co > 2 || has("gui_running")
set laststatus=2 " always show the status line
set statusline=%<%f%h%m%r%=%{&ff}\ %l,%c%V\ \ \tab\:%{ShowTab()}\ %P
fu ShowTab()
return (indent('.') / &ts )
endf
set linespace=1 " space it out a little more (easier to read)
set wildmenu " turn on wild menu, try typing :h and press <Tab>
set ai " autoindent
set si " smartindent
set fo=tcrqn " see help (complex)
set cindent " do C-style indenting
set tabstop=4 " tab spacing (settings below are just to unify it)
set softtabstop=4 " unify
set shiftwidth=4 " unify
set noexpandtab " real tabs please!
set smarttab " use tabs at the start of a line, spaces elsewhere
set nowrap " do not wrap lines
" Use a sufficiently wide window automatically when started as "gvimdiff"
if (&foldmethod == 'diff')
set columns=165
endif
endif
" {{{ Our default /bin/ish is bash, not ksh, so syntax highlighting for .sh
" files should default to bash. See :help sh-syntax and bug #101819.
if has("eval")
let is_bash=1
endif
" }}}
" {{{ Autocommandsi
if has("autocmd")
endif " has("autocmd")
" }}}
" 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='latex'
"EOF .gvimrc 在这里结束
#############################################
4. 建立~/.vim/ftplugin/tex.vim,内容为:
" this is mostly a matter of taste. but LaTeX looks good with just a bit
" of indentation.
set sw=2
" TIP: if you write your \label's as \label{fig:something}, then if you
" type in \ref{fig: and press <C-n> you will automatically cycle through
" all the figure labels. Very useful!
set iskeyword+=:
######################################################
5.反向搜索设置(dvi->source):
建立目录~/.vim/ftpplugin/tex,然后在~/.vim/ftplugin/tex/texrc 中找到如下代码【打开时可能要求选择适当的编码】:(如果没有这个文件,把~/.vim/ftplugin/latex-suite/texrc copy 过来)
" the option below specifies an editor for the dvi viewer while starting
" up the dvi viewer according to Dimitri Antoniou's tip on vim.sf.net (tip
" #225)
TexLet g:Tex_UseEditorSettingInDVIViewer = 0
把值设为1。如下:
TexLet g:Tex_UseEditorSettingInDVIViewer = 1
同时把dvi 编译选项设为
TexLet g:Tex_CompileRule_dvi = 'latex -src-specials -interaction=nonstopmode $*'
然后找到
if executable('xdg-open')
TexLet g:Tex_ViewRule_ps =
把紧接着的三行改为:
if executable('xdg-open')
TexLet g:Tex_ViewRule_ps = 'okular -unique'
TexLet g:Tex_ViewRule_pdf = 'okular -unique'
TexLet g:Tex_ViewRule_dvi = 'okular -unique'
再打开Okuar,把Editor设置为
gvim -c ":RemoteOpen +%l %f"
以后使用Shift+鼠标左键就可以实现inverse search了。
注意:到目前为止,还没有办法实现pdf和source之间的正反向搜索。不过编辑器Texworks可以实现。
6. 安装帮助文档
启动gvim,然后在标准模式输入
:helptags ~/.vim/doc
7. 以后你可以使用:help latex-suite.txt获得帮助
现在你就可以使用gvim file.tex进行编辑了
8. 为gvim添加启动项
其中Launcher Properties如下:
Type Application
Name GVIM
Command /usr/bin/gvim
Comment GVIM 4 LaTeX
icon /usr/share/pixmaps/vim.svg
9. 实现标签页功能
实际应用中,可使用 Shell 提供的别名功能,对 “gvim --remote-tab-silent” 这样的长命令行进行友好简化,做法是编辑 $HOME/.bashrc 文件,向其中添加:
#给gvim别名实现自动打开标签页
alias gvim='gvim --remote-tab-silent'
然后修改/usr/share/applications/gvim.desktop中的
#Exec=gvim -f %F
Exec=gvim
10. 添加Launcher bar
按照前面提到的方法添加/usr/share/applications/gvim.desktop就可以了
相关阅读 更多 +