vi设置

在vi编辑器里面命令模式选项
:set all       查看所有set选项
:set           显示当前set设置
:filetype on   通过$VIMRUNTIME/filetype.vim.打开文件类型检测
ubuntu 8.04默认的vi编辑器不太好使,可以在终端输入
sudo apt-get install vim
安装vim
然后输入
sudo -s
密码
cd /etc/vim
vim vimrc

大致如下:
           
" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
" you can find below. If you wish to change any of those settings, you should
" do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
" everytime an upgrade of the vim packages is performed. It is recommended to
" make changes after sourcing debian.vim since it alters the value of the
" 'compatible' option.

" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim

" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
"set compatible

" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
"syntax on

" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
"set background=dark

" Uncomment the following to have Vim jump to the last position when
" reopening a file
"if has("autocmd")
" au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
   \| exe "normal g'\"" | endif
"endif

" Uncomment the following to have Vim load indentation rules according to the
" detected filetype. Per default Debian Vim only load filetype specific
" plugins.
"if has("autocmd")
" filetype indent on
"endif

" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
"set showcmd        " Show (partial) command in status line.
"set showmatch        " Show matching brackets.
"set ignorecase        " Do case insensitive matching
"set smartcase        " Do smart case matching
"set incsearch        " Incremental search
"set autowrite        " Automatically save before commands like :next and :make
"set hidden             " Hide buffers when they are abandoned
"set mouse=a        " Enable mouse usage (all modes) in terminals

" Source a global configuration file if available
" XXX Deprecated, please move your changes here in /etc/vim/vimrc
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif



""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""Custom vim setting""以下为自己添加的一些简单设置
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
"有两个的只能取其一
set ai/noai                  " 自动缩进,新行与前面的行保持—致的自动空格/不自动空格(缺省)
set aw/noaw                  " 自动写,转入shell或使用:n编辑其他文件时,当前的缓冲区被写入/不写
set flash/noflash            " 在出错处闪烁但不呜叫(缺省)/使用呜叫而不闪烁
set ic/noic                  " 在查询及模式匹配时忽赂大小写/不忽略大小写(缺省)
set nu/nonu         
set number/nonumber         " 屏幕左边显示行号/不显示行号(缺省)
set showmatch                " 显示括号配对,当键入“]”“)”时,高亮度显示匹配的括号/缺省不高亮
set showmode                 " 处于文本输入方式时加亮按钮条中的模式指示器/缺省不指示当前模式
set showcmd                  " 在状态栏显示目前所执行的指令,未完成的指令片段亦会显示出来
set warn/nowarn              " 对文本进行了新的修改后,离开shell时系统给出显示(缺省)
set ws/nows                  " 在搜索时如到达文件尾则绕回文件头继续搜索
set wrap/nowrap             " 长行显示自动折行
colorscheme evening         " 设定背景为夜间模式
filetype plugin on          " 自动识别文件类型,自动匹配对应的, “文件类型Plugin.vim”文件,使用缩进定义文件
set autoindent              " 设置自动缩进:即每行的缩进值与上一行相等;使用 noautoindent 取消设置
set cindent            " 以C/C++的模式缩进
set noignorecase            " 默认区分大小写 
set ruler                   " 打开状态栏标尺
set scrolloff=5             " 设定光标离窗口上下边界 5 行时窗口自动滚动
set shiftwidth=4            " 设定 << 和 >> 命令移动时的宽度为 4
set softtabstop=4           " 使得按退格键时可以一次删掉 4 个空格,不足 4 个时删掉所有剩下的空格)
set tabstop=4               " 设定 tab 长度为 4
set wrap                    " 自动换行显示
syntax enable
syntax on                   " 自动语法高亮


另外,set background=dark 没有效果,不知怎么回事,请高手赐教!!

你可能感兴趣的:(vi设置)