
Vim是Linux上著名的文本编辑器. 早年他是Vi编辑器的增强版. gVim是Windows版本,具有标准的Windows样式图形界面,因此称为g(图形)Vim. 如果非人士使用它,则它们之间的差异很小(Vim和gVim). Vim和Emacs都被称为工件,并形成两个主要派系. 尽管我非常希望两党能够融洽相处,但现实情况是,没有人能够说服对方.
Vim功能强大的原因之一是,它赋予用户最大的控制权,允许用户自由配置并转换为他们想要的任何形式. 安装Vim后,默认配置文件就像一张空白纸,需要您进行绘制. 让我们看一下配置后的效果(单击以查看高分辨率原始图像):


(1)Vim语法高亮显示,行号,自动缩进等.


(2)Vim目录树(需要小的插件,下载位于本文结尾)

下面与您共享我使用的gVim配置文件,该文件也适用于Vim. Windows下Vim的配置文件位置: D: / Program Files / Vim_vimrc(即您的Vim安装位置gvim 配置文件,我安装在D: / Program Files中); Linux下Vim的配置文件位置: / etc / vim / gvimrc.
请根据需要添加和修改. 例如,如果您没有与C ++ / JAVA联系,则以后无需添加相关配置. 如果愿意,可以全部拿走. 最后将其添加到相应的配置文件中(注意: 类似的配色方案是注释,请确保左双引号是半角):

" 配色方案 colo liveme " 编码设置 set enc=utf-8
set fencs=utf-8,ucs-bom,shift-jis,gb18030,gbk,gb2312,cp936 " 设置菜单语言 set langmenu=zh_CN.UTF-8 " 导入删除菜单脚本,删除乱码的菜单 source $VIMRUNTIME/delmenu.vim " 导入正常的菜单脚本 source $VIMRUNTIME/menu.vim " 设置提示信息语言 language messages zh_CN.utf-8 " 字体设置 set guifont=Monaco:h12:cANSI " 语法高亮 set syntax=on " 自动缩进 set autoindent " C语言方式缩进 set cindent " 智能缩进 set smartindent " 统一缩进为4 set softtabstop=4
set shiftwidth=4 " 默认窗口大小 set lines=30 columns=82 " 自动换行 set wrap " 整词换行 set linebreak " 显示行号 set number " 高亮显示匹配的括号 set showmatch " 搜索逐字符高亮和实时搜索 set hlsearch
set incsearch " 匹配括号高亮的时间(单位是十分之一秒) set matchtime=5 " 显示括号配对情况 set showmatch " 代码折叠 " set fdm=indent " 选择代码折叠类型 set foldmethod=syntax " 禁止自动折叠 set foldlevel=100 " 命令行(在状态行下)的高度,默认为1,这里是2 set cmdheight=2 " 历史记录数 set history=1000 " 侦测文件类型 filetype on " 为特定文件类型载入相关缩进格式 filetype indent on " 为特定的文件类型载入对应的插件 filetype plugin on
filetype plugin indent on " 不与vi兼容 set nocp " vim目录树插件 map <F10> :NERDTreeToggle<CR> " 保存全局变量 set viminfo+=! " 带有如下符号的单词不要被换行分割 set iskeyword+=_,$,@,%,#,- " 字符间插入的像素行数目 set linespace=0 " 增强模式中的命令行自动完成操作 set wildmenu " PHP语法提示 autocmd FileType php set omnifunc=phpcomplete " 禁止生成临时文件 set nobackup
set noswapfile " 设置退格键可用 set backspace=2 " 快捷键自定义 map <C-s> :w<CR>
imap <C-s> <C-o>:w<CR> " 隐藏工具栏,可用快捷键F2切换 set guioptions-=T
map <silent> <F2> :if &guioptions =~# 'T' <Bar>
set guioptions-=T <Bar>
else <Bar>
set guioptions+=T <Bar>
endif<CR> " 能够漂亮地显示.NFO文件 set encoding=utf-8
function! SetFileEncodings(encodings)
let b:myfileencodingsbak=&fileencodings
let &fileencodings=a:encodings
endfunction
function! RestoreFileEncodings()
let &fileencodings=b:myfileencodingsbak
unlet b:myfileencodingsbak
endfunction
au BufReadPre *.nfo call SetFileEncodings('cp437')|set ambiwidth=single
au BufReadPost *.nfo call RestoreFileEncodings() " F5编译和运行C程序,F6编译和运行C++程序 " C的编译和运行 map <F5> :call CompileRunGcc()<CR>
func! CompileRunGcc()
exec "w"
exec "!gcc -Wall % -o %<"
exec "! ./%<"
endfunc " C++的编译和运行 map <F6> :call CompileRunGpp()<CR>
func! CompileRunGpp()
exec "w"
exec "!g++ -Wall % -o %<"
exec "! ./%<"
endfunc " Gvim标签定制 set guitablabel=%{ShortTabLabel()}
function ShortTabLabel ()
let bufnrlist = tabpagebuflist (v:lnum)
let label = bufname (bufnrlist[tabpagewinnr (v:lnum) -1])
let filename = fnamemodify (label, ':t')
return filename
endfunction " ######### 一键保存和编译 ######### " "编译C源文件 func! CompileGcc()
exec "w"
let compilecmd="!gcc -Wall -std=c99 "
let compileflag="-o %<"
exec compilecmd." % ".compileflag
endfunc " 编译C++源文件 func! CompileCpp()
exec "w"
let compilecmd="!g++ -Wall "
let compileflag="-o %<"
exec compilecmd." % ".compileflag
endfunc " 编译&链接Go源文件 func! CompileGo()
exec "w"
exec "!8g %"
exec "!8l -o %<.exe %<.8"
endfunc " 编译Haskell源文件 func! CompileHaskell()
exec "w"
let compilecmd="!ghc --make "
let compileflag="-o %<"
exec compilecmd." % ".compileflag
endfunc " 编译Java源文件 func! CompileJava()
exec "w"
exec "!javac %"
endfunc " 编译C#源文件 func! CompileCs()
exec "w"
exec "!csc %"
endfunc " 编译Gas源文件 func! CompileGas()
exec "w"
exec "!gcc -Wall -ggdb -o %< %"
endfunc " 运行Shell源文件 func! RunShell()
exec "w"
exec "!sh %"
endfunc " 运行Lua源文件 func! RunLua()
exec "w"
exec "!lua %"
endfunc " 运行Perl源文件 func! RunPerl()
exec "w"
exec "!perl %"
endfunc " 运行Python源文件 func! RunPython()
exec "w"
exec "!python %"
endfunc " 运行Ruby源文件 func! RunRuby()
exec "w"
exec "!ruby %"
endfunc " 根据文件类型自动选择相应的编译函数 func! CompileCode()
exec "w"
if &filetype == "c"
exec "call CompileGcc()"
elseif &filetype == "cpp"
exec "call CompileCpp()"
elseif &filetype == "go"
exec "call CompileGo()"
elseif &filetype == "haskell"
exec "call CompileHaskell()"
elseif &filetype == "java"
exec "call CompileJava()"
elseif &filetype == "cs"
exec "call CompileCs()"
elseif &filetype == "asm"
exec "call CompileGas()"
elseif &filetype == "sh"
exec "call RunShell()"
elseif &filetype == "lua"
exec "call RunLua()"
elseif &filetype == "perl"
exec "call RunPerl()"
elseif &filetype == "python"
exec "call RunPython()"
elseif &filetype == "ruby"
exec "call RunRuby()"
endif
endfunc " 运行可执行文件 func! RunResult()
exec "w"
if &filetype == "c"
exec "! %<"
elseif &filetype == "cpp"
exec "! %<"
elseif &filetype == "go"
exec "! %<"
elseif &filetype == "haskell"
exec "! %<"
elseif &filetype == "java"
exec "!java %<"
elseif &filetype == "cs"
exec "! %<"
elseif &filetype == "asm"
exec "! %<"
elseif &filetype == "sh"
exec "!sh %<.sh"
elseif &filetype == "lua"
exec "!lua %<.lua"
elseif &filetype == "perl"
exec "!perl %<.pl"
elseif &filetype == "python"
exec "!python %<.py"
elseif &filetype == "ruby"
exec "!ruby %<.rb"
endif
endfunc
附加: Vim配置文件下载: Vim配置文件
使用配置文件,我无法实现上述效果gvim 配置文件,并且需要一种配色方案. 为了使每个人都易于使用,并且不损坏原始的Vim文件,此颜色方案从沙漠更改了,因此我将其重命名为liveme,绿色和环保. 使用方法: 下载以下liveme.vim文件,并将其放在Vim安装目录中的vim73colors下.
gVim(Vim)配色方案下载: liveme.vim
附件: 目录树插件下载: NERD_tree.zip(用法: 提取三个文件夹,并将它们放在Vim安装目录的vimfiles文件夹中,合并具有相同名称的文件夹. 目录树切换快捷方式: F10) >
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-171226-1.html
经济下滑并不全是坏事