Vim-LaTeX for Windows配置

本文详细介绍如何在Gvim中配置LaTeX环境,包括下载和安装Gvim、vim-latex插件,设置编译和阅读器,以及配置vimrc文件以优化编辑体验,实现LaTeX写作的即时可视化。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、下载Gvim
2、下载vim-latex并解压(这里是vim-latex-1.10.0)
3、将vim-latex-1.10.0\vim-latex-1.10.0下所有文件拷贝到~\Vim\vimfiles\文件夹下

4、添加用户环境变量

  • LaTeX版本:texlive2015
    ~\texlive\2015\bin\win32;
  • 阅读器版本:SumatraPDF
    ~\SumatraPDF\SumatraPDF.exe

5、设置默认便编译为pdf,设置默认阅读器为SumatraPDF(简约)
方法:修改~/.vim/ftplugin/latex-suite/texrc

  • 第88到92行
    88 if has(‘macunix’)
    89 TexLet g:Tex_DefaultTargetFormat = ‘pdf’
    90 else
    91 TexLet g:Tex_DefaultTargetFormat = ‘pdf’ # 默认为pdf
    92 endif

  • 修改145行:
    142 elseif has(‘macunix’)
    143 " Let the system pick. If you want, you can override the choice here.
    144 TexLet g:Tex_ViewRule_ps = ‘’
    145 TexLet g:Tex_ViewRule_pdf = ‘SumatraPDF’ # 默认阅读器为SumatraPDF

实时可视化
安装strawberry
sublime

6、修改vim配置文件

source $VIMRUNTIME/vimrc_example.vim

set diffexpr=MyDiff()
function MyDiff()
  let opt = '-a --binary '
  if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
  if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
  let arg1 = v:fname_in
  if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
  let arg1 = substitute(arg1, '!', '\!', 'g')
  let arg2 = v:fname_new
  if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
  let arg2 = substitute(arg2, '!', '\!', 'g')
  let arg3 = v:fname_out
  if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
  let arg3 = substitute(arg3, '!', '\!', 'g')
  if $VIMRUNTIME =~ ' '
    if &sh =~ '\<cmd'
      if empty(&shellxquote)
        let l:shxq_sav = ''
        set shellxquote&
      endif
      let cmd = '"' . $VIMRUNTIME . '\diff"'
    else
      let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
    endif
  else
    let cmd = $VIMRUNTIME . '\diff'
  endif
  let cmd = substitute(cmd, '!', '\!', 'g')
  silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
  if exists('l:shxq_sav')
    let &shellxquote=l:shxq_sav
  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

" 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'

let g:Tex_FormatDependency_pdf = 'dvi,ps,pdf'
let g:Tex_CompileRule_dvi = 'latex --interaction=nonstopmode $*'
let g:Tex_CompileRule_ps = 'dvips -Ppdf -o $*.ps $*.dvi'
let g:Tex_CompileRule_pdf = 'ps2pdf $*.ps'
let g:Tex_ViewRule_pdf = 'd:/ProgramFiles64/SumatraPDF/SumatraPDF.exe'
let g:Tex_ViewRule_pdfs = 'd:/ProgramFiles64/SumatraPDF/SumatraPDF.exe'
let g:Tex_ViewRule_pdfm = 'd:/ProgramFiles64/SumatraPDF/SumatraPDF.exe'
let g:Tex_ViewRule_pdfx = 'd:/ProgramFiles64/SumatraPDF/SumatraPDF.exe'

set fileencodings=ucs-bom,utf-8,chinese,cp936
set encoding=utf-8
set termencoding=utf-8
set fileencoding=utf-8
source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim


set tags=tags;
set autochdir

let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1

let g:winManagerWindowLayout='FileExplorer|TagList'
nmap wm :WMToggle<cr>

let g:miniBufExplMapCTabSwitchBufs=1
let g:miniBufExplMapWindowsNavVim=1
let g:miniBufExplMapWindowNavArrows=1

nnoremap <silent> <F12> :A<CR>
nnoremap <silent> <F3> :Grep<CR>

map    <F9>   <ESC>:w<CR>,ll   "F9保存并编译
imap   <F9>   <ESC>:w<CR>,ll
map    <F10>   <ESC>,lv        "F10查看
imap   <F10>   <ESC>,lv


" Startup {{{
filetype indent plugin on

augroup vimrcEx
au!

autocmd FileType text setlocal textwidth=78

augroup END

" vim 文件折叠方式为 marker
augroup ft_vim
    au!

    autocmd FileType vim setlocal foldmethod=marker

    " 打开文件总是定位到上次编辑的位置
    autocmd BufReadPost *
      \ if line("'\"") > 1 && line("'\"") <= line("$") |
      \   exe "normal! g`\"" |
      \ endif

    augroup END
augroup END
" }}}


" General {{{
set nocompatible
set nobackup
set noswapfile
set history=1024
set autochdir
set whichwrap=b,s,<,>,[,]
set nobomb
set backspace=indent,eol,start whichwrap+=<,>,[,]
" Vim 的默认寄存器和系统剪贴板共享
set clipboard+=unnamed
" 设置 alt 键不映射到菜单栏
set winaltkeys=no
" }}}


" GUI {{{
colorscheme evening

source $VIMRUNTIME/delmenu.vim
source $VIMRUNTIME/menu.vim
set cursorline
set hlsearch
set number
" 窗口大小
set lines=35 columns=140
" 分割出来的窗口位于当前窗口下边/右边
set splitbelow
set splitright
" }}}


" Format {{{
set autoindent
set smartindent
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set foldmethod=indent
syntax on
" }}}


" Keymap {{{
let mapleader=","

nmap <leader>s :source $VIM/_vimrc<cr>
nmap <leader>e :e $VIM/_vimrc<cr>

map <leader>tn :tabnew<cr>
map <leader>tc :tabclose<cr>
map <leader>th :tabp<cr>
map <leader>tl :tabn<cr>

" 移动分割窗口
nmap <C-j> <C-W>j
nmap <C-k> <C-W>k
nmap <C-h> <C-W>h
nmap <C-l> <C-W>l

" 正常模式下 alt+j,k,h,l 调整分割窗口大小
nnoremap <M-j> :resize +5<cr>
nnoremap <M-k> :resize -5<cr>
nnoremap <M-h> :vertical resize -5<cr>
nnoremap <M-l> :vertical resize +5<cr>

" 插入模式移动光标 alt + 方向键
inoremap <M-j> <Down>
inoremap <M-k> <Up>
inoremap <M-h> <left>
inoremap <M-l> <Right>

" IDE like delete
inoremap <C-BS> <Esc>bdei

nnoremap vv ^vg_
" 转换当前行为大写
inoremap <C-u> <esc>mzgUiw`za
" 命令模式下的行首尾
cnoremap <C-a> <home>
cnoremap <C-e> <end>

nnoremap <F2> :setlocal number!<cr>
nnoremap <leader>w :set wrap!<cr>

imap <C-v> "+gP
vmap <C-c> "+y
vnoremap <BS> d
vnoremap <C-C> "+y
vnoremap <C-Insert> "+y
imap <C-V>		"+gP
map <S-Insert>		"+gP
cmap <C-V>		<C-R>+
cmap <S-Insert>		<C-R>+

exe 'inoremap <script> <C-V>' paste#paste_cmd['i']
exe 'vnoremap <script> <C-V>' paste#paste_cmd['v']

" 打开当前目录 windows
map <leader>ex :!start explorer %:p:h<CR>

" 打开当前目录CMD
map <leader>cmd :!start<cr>
" 打印当前时间
map <F3> a<C-R>=strftime("%Y-%m-%d %a %I:%M %p")<CR><Esc>

" 复制当前文件/路径到剪贴板
nmap ,fn :let @*=substitute(expand("%"), "/", "\\", "g")<CR>
nmap ,fp :let @*=substitute(expand("%:p"), "/", "\\", "g")<CR>

" 设置切换Buffer快捷键"
nnoremap <C-left> :bn<CR>
nnoremap <C-right> :bp<CR>

" }}}


" Plugin {{{
filetype off

set rtp+=$VIM/vimfiles/bundle/Vundle.vim
call vundle#begin('$VIM/vimfiles/bundle')

" ----- Vundle ----- {{{
Plugin 'VundleVim/Vundle.vim'
" }}}
" ----- NerdTree ----- {{{
Plugin 'scrooloose/nerdtree'

let NERDTreeIgnore=['.idea', '.vscode', 'node_modules', '*.pyc']
let NERDTreeBookmarksFile = $VIM . '/NERDTreeBookmarks'
let NERDTreeMinimalUI = 1
let NERDTreeBookmarksSort = 1
let NERDTreeShowLineNumbers = 0
let NERDTreeShowBookmarks = 1
let g:NERDTreeWinPos = 'right'
let g:NERDTreeDirArrowExpandable = '?'
let g:NERDTreeDirArrowCollapsible = '?'
nmap <leader>n :NERDTreeToggle <cr>
if exists('g:NERDTreeWinPos')
    autocmd vimenter * NERDTree D:\repo
endif
" }}}
" ----- Multiple-cursors ----- {{{
Plugin 'terryma/vim-multiple-cursors'
" }}}
" ----- Tabular ----- {{{
Plugin 'godlygeek/tabular'
" }}}
" ----- Markdown ----- {{{
Plugin 'plasticboy/vim-markdown'
" }}}
" ----- Airline ----- {{{
"Plugin 'vim-airline/vim-airline'
"Plugin 'vim-airline/vim-airline-themes'
"set laststatus=2

"if !exists('g:airline_symbols')
    "let g:airline_symbols = {}
"endif
"let g:airline_theme='tomorrow'
"let g:airline_powerline_fonts = 1
"let g:Powerline_symbols='fancy'

" let g:airline_symbols.branch = ''
" let g:airline_left_sep = '?'
" let g:airline_right_sep = '?'
"let g:airline#extensions#branch#enabled = 1
"let g:airline#extensions#branch#vcs_priority = ["git", "mercurial"]
" let g:airline_mode_map = {
" \ 'n'  : 'N',
" \ 'i'  : 'I',
" \ 'v'  : 'V',
" \ }
" let g:airline#extensions#tabline#enabled = 1

" }}}
" ----- Ctrlp ----- {{{
Plugin 'kien/ctrlp.vim'
let g:ctrlp_match_window = 'bottom,order:btt,min:1,max:10,results:10'
set wildignore+=*\\.git\\*,*\\tmp\\*,*.swp,*.zip,*.exe,*.pyc
" }}}
" ----- Nerdcommenter ----- {{{
Plugin 'scrooloose/nerdcommenter'
" }}}
" ----- Emmet ----- {{{
Plugin 'mattn/emmet-vim'
" }}}
" ----- SnipMate ----- {{{
Plugin 'MarcWeber/vim-addon-mw-utils'
Plugin 'tomtom/tlib_vim'
Plugin 'garbas/vim-snipmate'
" Replace your repo
Plugin 'keelii/vim-snippets'
" Allow for vimrc re-sourcing
let g:snipMate = get(g:, 'snipMate', {})
" }}}
" ----- Fugitive ----- {{{
Plugin 'tpope/vim-fugitive'
" }}}
" ----- Neocomplete ----- {{{
Plugin 'Shougo/neocomplete.vim'
let g:acp_enableAtStartup = 0
" Use neocomplete.
let g:neocomplete#enable_at_startup = 1
" Use smartcase.
let g:neocomplete#enable_smart_case = 1
let g:neocomplete#enable_auto_select = 1
" Enable snipMate compatibility feature.
let g:neosnippet#enable_snipmate_compatibility = 1
" Tell Neosnippet about the other snippets
let g:neosnippet#snippets_directory=$VIM . '/vimfiles/bundle/vim-snippets/snippets'

" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
autocmd FileType html,markdown setlocal omnifunc=htmlcomplete#CompleteTags
autocmd FileType javascript setlocal omnifunc=javascriptcomplete#CompleteJS
autocmd FileType python setlocal omnifunc=pythoncomplete#Complete
autocmd FileType xml setlocal omnifunc=xmlcomplete#CompleteTags
if !exists('g:neocomplete#sources#omni#input_patterns')
  let g:neocomplete#sources#omni#input_patterns = {}
endif
" }}}

filetype on
call vundle#end()
" }}}

" Function {{{
" Remove trailing whitespace when writing a buffer, but not for diff files.
" From: Vigil
" @see http://blog.bs2.to/post/EdwardLee/17961
function! RemoveTrailingWhitespace()
    if &ft != "diff"
        let b:curcol = col(".")
        let b:curline = line(".")
        silent! %s/\s\+$//
        silent! %s/\(\s*\n\)\+\%$//
        call cursor(b:curline, b:curcol)
    endif
endfunction
autocmd BufWritePre * call RemoveTrailingWhitespace()
" }}}

参考文献

【1】可能是 Windows 下最漂亮的 Gvim 配置了
【2】手把手教你把Vim改装成一个IDE编程环境(图文)
【3】用Gvim建立IDE编程环境 (Windows篇)
【4】用Gvim和SumatraPDF实现latex写作即时可视化
【5】LaTeXTools
【6】使用Latexmk
【7】VIM学习笔记 插件管理器(Vundle)
【8】windows7下TexLive2016的安装和配置

<think>好的,用户问的是如何在Windows上安装Git,我需要根据提供的引用内容来组织回答。首先,我得确认引用的信息是否足够覆盖安装步骤。引用1提到了下载、安装、配置Git,引用2提到了最新的版本号和安装包,引用3是Git的简介,引用4关于凭证管理器,引用5有安装步骤的细节。 用户需要的是安装教程,所以应该分步骤说明。第一步是下载,引用2提到版本号是Git-2.37.2.2,但用户现在可能版本更新了,所以应该建议到官网下载。引用1中的步骤1就是下载,引用5也提到了下载安装包。 安装步骤,引用1的步骤2安装Git,引用5中的图2-9可能涉及安装选项,比如路径选择、组件选择,这里需要详细说明。例如,选择组件的时候,建议默认选项,或者根据用户需要调整。还有安装过程中的配置选项,比如选择默认编辑器、调整PATH环境等,这些在引用5中可能有提到。 配置部分,引用1的步骤3配置Git,包括用户名和邮箱,这需要用户自己设置。引用4提到的凭证管理器可能在安装过程中有选项,需要提醒用户启用,以便安全存储凭证。 需要注意LaTeX格式的使用,比如行内公式用$...$,但这里可能用不上数学公式,所以可能不需要。不过要确保结构清晰,分步骤,代码块用正确格式。引用标记要放在相关步骤的末尾,比如下载步骤引用2,安装步骤引用5,配置部分引用1和4。 可能需要检查是否有遗漏的步骤,比如安装后的验证,运行git --version,但引用中没有提到,不过作为教程应该包含。这部分可能需要自己补充,但因为没有引用支持,可能不添加。或者看看引用中是否有相关信息。 此外,用户可能关心安装后的基本配置,比如设置用户名和邮箱,这部分在引用1的配置步骤里,必须包含。 现在组织步骤: 1. 下载安装包:访问官网,下载最新版,引用2和引用1的步骤1。 2. 运行安装程序:安装步骤,选择路径,组件选择,引用5中的安装过程,注意选项如凭证管理器(引用4)。 3. 配置Git:设置用户名和邮箱,引用1的步骤3。 相关问题部分,需要生成相关问题,比如如何配置用户信息,如何更新Git,如何使用凭证管理器,这些在引用中有涉及。 最后确保回答符合系统指令,结构清晰,步骤正确,引用正确标注。可能需要注意引用[^5]提到的是安装时的选项,比如保持默认选择,所以在安装步骤中需要提到保持默认选项,除非有特殊需求。</think>### 如何在Windows操作系统上安装Git教程 以下是Windows系统上安装Git的详细步骤: --- #### **1. 下载Git安装包** - 访问Git官网 [https://git-scm.com](https://git-scm.com),点击“Download for Windows”下载最新版本的安装包[^2]。 - 截至2022年8月,最新版本为`Git-2.37.2.2`,但官网会持续更新版本[^2]。 --- #### **2. 运行安装程序** 1. **启动安装包**:双击下载的`.exe`文件(如`Git-2.37.2.2-64-bit.exe`)开始安装。 2. **选择安装路径**:默认路径为`C:\Program Files\Git`,可自定义或保持默认[^5]。 3. **组件选择**: - 勾选`Windows Explorer integration`(右键菜单集成) - 勾选`Git Bash Here`和`Git GUI Here`(命令行工具) - 勾选`Enable Git Credential Manager`以启用凭证管理功能(推荐,支持多因素认证)[^4]。 4. **其他配置**: - 选择默认编辑器(如Vim或VSCode) - 调整环境变量时建议选择**“Use Git from Git Bash only”**(避免与系统工具冲突)。 5. **完成安装**:单击`Install`开始安装,完成后单击`Finish`退出向导[^5]。 --- #### **3. 配置Git** 1. **打开Git Bash**:在开始菜单中找到`Git Bash`并启动。 2. **设置用户名和邮箱**(必需步骤): ```bash git config --global user.name "Your Name" git config --global user.email "your.email@example.com" ``` 此配置将用于标识代码提交者身份[^1][^3]。 --- #### **验证安装** 在命令行输入以下命令,若显示版本号则安装成功: ```bash git --version ``` --- ###
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值