灯火互联
管理员
管理员
  • 注册日期2011-07-27
  • 发帖数41778
  • QQ
  • 火币41290枚
  • 粉丝1086
  • 关注100
  • 终身成就奖
  • 最爱沙发
  • 忠实会员
  • 灌水天才奖
  • 贴图大师奖
  • 原创先锋奖
  • 特殊贡献奖
  • 宣传大使奖
  • 优秀斑竹奖
  • 社区明星
阅读:1579回复:0

Debian中VI的配置方法简析

楼主#
更多 发布于:2012-08-27 14:56


刚刚安装了Debian,却发现其自带的VI存在问题:

1)不支持语法高亮提示
2)不支持Backspace键的删除功能
原来Debian中自带的VI是VIM-TINY,程序本身就是不支持语法高亮和Backspace删除功能。

可以使用以下办法解决:
1)重新安装其它版本的VI
  apt-get install vim vim-runtime ctags
2)配置~/.vimrc  
  添加syntax on
VI常用的配置选项
-----------------------
set number
set showcmd
set incsearch
set expandtab
set showcmd
set history=400
set autoread
set ffs=unix,mac,DOS
set hlsearch
set shiftwidth=2
set wrap
set ai
set si
set cindent
set termencoding=unix
set tabstop=2
set nocompatible
set showmatch
set fileencodings=utf-8,gb2312,18030,gbk
set fileformats=unix
set ttyfast
syntax on
set imcmdline
set previewwindow
set showfulltag
set cursorline
set ruler
" set mouse=a

" Close the error bells
set vb t_vb=
set nowrapscan

" When open a file, it will jump to the last cursor position
if has("autocmd")
autocmd BufReadPost *
/ if line("'/"") > 0 ;; line ("'/"") <= line("$") |
/   exe "normal! g'/"" |
/ endif
endif

" For ctags
set tags=tags;
set autochdir

" For taglist
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
let Tlist_Auto_Open=1
set updatetime=100

" For auto complete '(' and '{'
ino ( ()<esc>:let leavechar=")"<cr>i
ino { {}<esc>:let leavechar="}"<cr>i
ino ' ''<esc>:let leavechar="'"<cr>i
ino " ""<esc>:let leavechar='"'<cr>i
imap <c-l> <esc>:exec "normal f" . leavechar<cr>a
  www.atcpu.com  
" For comment in C program /**/
set comments=s1:/*,mb:*,ex0:/

VI最常用操作
-----------------
i
  进入编辑状态可在光标处插入内容
o
  在当前行下方插入空白行并进入编辑状态
O
  在当前行上方插入空白行并进入编辑状态
D
  删除当前行光标后的所有内容
dd
  删除当前行
gg
  跳至文件顶部
G
  跳至文件底部
0
  移至本行开头
$
  移至本行末尾
x
  删除
CTRL+u
  向上翻页
CTRL+d
  向下翻页
yw
  复制光标所在单词
yy
  复制当前行
p
  粘贴至光标后
P
  粘贴至光标前
#
  查找与当前光标相同的单词或字符并高亮显示
/
  查找字符串
p
  以分栏方式打开另一文件
CTRL+ww
  在分栏方式打开的多个文件之间跳转
:num
  跳至文本的第num行
:g/str1/s//str2/
  用字符串str2替换文本中所有的str1
:x
  保存退出
:q!
  不保存退出





喜欢0 评分0
游客

返回顶部