""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Linux vim config (/etc/vimrc) """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Use Vim defaults (much better!) " This should the priority setting, otherwise problems can appear """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set nocompatible """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 编码设置 " fileformats(ffs)(vim才有)可指定多个,会依载入的档案形式来调整ff。 " 例如:set ffs=unix, dos ff=unix则预设为unix格式,但如读入的是dos格式的 " 档案,会自动调整为dos格式,这样存档时就会以dos格式存档。设置即为: " set fileformats=unix " set fileformat=unix并不会依据载入的档案形式来调整ff,并且只用unix形式 " 所以,可以解决windows下的^M问题。 " :set ff 可以查看当前文件fileformat " :set ffs 查看vim设置 " 其实fileformats可以这样调整 " set fileformats=unix,dos 这样也应该是可以解决^M问题的,让vim自动 " 去选择是用dos,还是unix的,这应该是vim的默认设置, " 当然也可以选择全局替换:%s/^M//g """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set fileencodings=utf-8,gb2312,gbk,gb18030 set termencoding=utf-8 set fileformat=unix "set fileformats=unix set encoding=prc set bs=indent,eol,start " allow backspacing over everything in insert mode set ai " always set autoindenting on set viminfo='20,\"50 " read/write a .viminfo file, don't store more " than 50 lines of registers " Only do this part when compiled with support for autocommands if has("autocmd") augroup redhat autocmd! " In text files, always limit the width of text to 78 characters autocmd BufRead *.txt set tw=78 " When editing a file, always jump to the last cursor position autocmd BufReadPost * \ if line("'\"") > 0 && line ("'\"") <= line("$") | \ exe "normal! g'\"" | \ endif " don't write swapfile on most commonly used directories for NFS mounts or USB sticks autocmd BufNewFile,BufReadPre /media/*,/mnt/* set directory=~/tmp,/var/tmp,/tmp " start with spec file template autocmd BufNewFile *.spec 0r /usr/share/vim/vimfiles/template.spec augroup END endif if has("cscope") && filereadable("/usr/bin/cscope") set csprg=/usr/bin/cscope set csto=0 set cst set nocsverb " add any database in current directory if filereadable("cscope.out") cs add cscope.out " else add database pointed to by environment elseif $CSCOPE_DB != "" cs add $CSCOPE_DB endif set csverb endif " 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 if &term=="xterm" set t_Co=8 set t_Sb=[4%dm set t_Sf=[3%dm endif """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 检测文件类型 " 载入文件类型插件 " 为特定文件类型载入相关缩进文件 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" filetype on filetype plugin on filetype indent on """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " GUI config """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set ruler " show the cursor position all the time set shortmess=atl " 启动的时候不显示援助索马里儿童的提示 set scrolloff=3 " 光标移动到buffer的顶部和底部时保持3行距离 " Don't wake up system with blinking cursor: let &guicursor = &guicursor . ",a:blinkon0" set history=50 " keep 50 lines of command line history set number " 显示行号 set nobackup " no backup file """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 缩进 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" set tabstop=4 " 设定 tab 长度为4 set shiftwidth=4 " 缩进的空格数 set expandtab " 是否在缩进和遇到Tab键时使用空格代替;使用noexpandtab取消设置 set autoindent " 自动缩进 set smartindent set cindent " Automatically adjust the indented length """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " python config """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 自动补全 " 配置说明 " 1. 下载pydiction, pydiction中包括了complete-dict和python_pydiction.vim " 2. cp complete-dict to /home/tony/.vim/dict/pydiction/ " cp python_pydiction to /home/tony/.vim/plugin/ " 3. $ sudo vim /etc/vimrc " add: " filetype plugin on " let g:pydiction_location = '/home/tony/.vim/dict/pydiction/complete-dict' """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " 快捷键说明 " 需要补全到时候,按住tab键,便可以看到补全的内容 " 然后通过ctrl-n, ctrl-p可以上下选择 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" filetype plugin on let g:pydiction_location = '/home/tony/.vim/dict/pydiction/complete-dict' """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Tag list(ctags) " 配置说明 " 1. 安装ctags,正常yum中都会有提供 " 2. 下载taglist, 解压缩, 里面有doc/taglist.txt和plugin/taglist.vim " 3. cp taglist.vim to ~/.vim/plugin/ " cp taglist.txt to ~/.vim/doc/taglist.txt " 4. 使用ctags " $ cd ~/workspace/ProjectForge/ 此为源码到根目录 " $ ctags -R 此时目录里面就生成了一个tags文件 " $ vim ~/workspace/ProjectForge/filename.java 打开一个文件 " 在vim中运行命令: " :set tags=/home/tony/workspace/ProjectForge/tags 该命令将tags文件加入到 " vim中来,也可以将这句话放到~/.vimrc中去,如果经常在这个工程编程的话 " " 光标在源码出: " Ctrl + ] 会跳转到方法那 " Ctrl + t 又跳回到函数被调用的地方 " 5. 使用taglist " 进入Vim后用下面的命令打开taglist窗口 " :Tlist """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" let Tlist_Ctags_Cmd='/usr/bin/ctags' " 设定系统中ctags程序到位置 let Tlist_Show_One_file=1 " 不同时显示多个的tag,只显示当前文件的 let Tlist_Exit_OnlyWindow=1 " 如果taglist窗口是最后一个窗口,则推出vim "在右侧显示总是有点问题,那就默认显示在左侧,就很实用了。 "let Tlist_Use_Right_Window=1 " 在右侧窗口中显示taglist窗口 """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " winmanager config " 配置说明: " 1. 下载winmanager, 解压缩 " 2. 操作同taglist类似 " let g:winManagerWindowLayout='TagList|FileExplorer' 显示顺序,TagList在上,FileExplorer在下 " let g:winManagerWidth=30 30像素的宽度 " nmap wm :WMToggle 自定义快捷键 """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" let g:winManagerWindowLayout='TagList|FileExplorer' let g:winManagerWidth=30 nmap wm :WMToggle """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
Linux下vim配置
猜你喜欢
转载自greybeard.iteye.com/blog/1231995
今日推荐
周排行