ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Debian中VI的配置方法简析

Debian中VI的配置方法简析

Linux操作系统 作者:zhongguohaohan 时间:2015-01-07 14:03:54 0 删除 编辑

刚刚安装了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 ( ():let leavechar=")"i

ino { {}:let leavechar="}"i

ino ' '':let leavechar="'"i

ino " "":let leavechar='"'i

imap :exec "normal f" . leavechara

   

" 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

  粘贴至光标前

#

  查找与当前光标相同的单词或字符并高亮显示

/

  查找字符串

:sp

  以分栏方式打开另一文件

CTRL+ww

  在分栏方式打开的多个文件之间跳转

:num

  跳至文本的第num行

:g/str1/s//str2/

  用字符串str2替换文本中所有的str1

:x

  保存退出

:q!

  不保存退出

摘自 邵巍的专栏

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30094772/viewspace-1393249/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2015-01-06

  • 博文量
    58
  • 访问量
    49901