Linux安全网 - Linux操作系统_Linux 命令_Linux教程_Linux黑客

会员投稿 投稿指南 本期推荐:
搜索:
您的位置: Linux安全网 > Linux培训 > » 正文

Linux下vim配置

来源: 未知 分享至:
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Linux vim config
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Use Vim defaults (much better!)
" This should the priority setting, otherwise problems can appear
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible	
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" 编码设置
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set fileencodings=utf-8,gb2312,gbk,gb18030
set termencoding=utf-8
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窗口
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""


Tags:
分享至:
最新图文资讯
1 2 3 4 5 6
验证码:点击我更换图片 理智评论文明上网,拒绝恶意谩骂 用户名:
关于我们 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 发展历史