vim配置文件.vimrc

"语法高亮显示
1 syntax on
2 filetype on
3 filetype indent on

4 set backspace=indent,eol,start
设想这样一个情况: 当前光标前面有若干字母, 按下 i 键进入了 Insert模式, 然后输入了 3 个字母, 再按 5 下删除(Backspace)。 默认情况下,VIM 仅能删除新输入的 3 个字母, 然后喇叭“嘟嘟”响两声。 如果“set backspace=start”, 则可以在删除了新输入的 3 个字母之后, 继续向前删除原有的两个字符。再设想一个情况: 有若干行文字, 把光标移到中间某一行的行首, 按 i 键进入 Insert 模式, 然后按一下 Backspace。 默认情况下, 喇叭会“嘟”一声,然后没有任何动静。 如果“set backspace=eol”, 则可以删除前一行行末的回车,也就是说将两行拼接起来。当设置了自动缩进后, 如果前一行缩进了一定距离, 按下回车后, 下一行也会保持相同的缩进。默认情况下, 不能在 Insert 模式下直接按 Backspace 删除行首的缩进。如果“set backspace=indent”, 则可以开启这一项功能。上述三项功能, 可以选择其中一种或几种, 用逗号分隔各个选项。
5 set tabstop=4
6 set number
7
" 与windows共享剪贴板
8 set clipboard+=unnamed
9
" 设定颜色方案和字体
10 colorscheme desert
11 set guifont=Consolas:h12
12 set guifontset=仿宋_GB2312:h10
13 set encoding=cp936
14
" 用浅色高亮当前行
15 autocmd InsertLeave * se nocul
16 autocmd InsertEnter * se cul
17
"设置历史纪录-记录编辑位置
18 set viminfo='10,\"100,:20,%,n~/.viminfo
19 au BufReadPost * if line("'\"") > 0|if line("'\"") <=
    line("$")|exe("norm'\"")|else|exe "norm $"|endif|endif
20 set history=10
21
22 set whichwrap=b,s,<,>,[,]
默认情况下, 在 VIM 中当光标移到一行最左边的时候, 继续按左键,光标不能回到上一行的最右边。 同样地, 光标到了一行最右边的时候, 不能通过继续按右跳到下一行的最左边。
但是, 通过设置 whichwrap 可以对一部分按键开启这项功能。 如果想对某一个或几个按键开启到头后自动折向下一行的功能,可以把需要开启的键的代号写到 whichwrap 的参数列表中, 各个键之间使用逗号分隔。以下是 whichwrap 支持的按键名称列表:
b
在 Normal 或 Visual 模式下按删除(Backspace)键。
s
在 Normal 或 Visual 模式下按空格键。
h
在 Normal 或 Visual 模式下按 h 键。
l
在 Normal 或 Visual 模式下按 l 键。
>
在 Normal 或 Visual 模式下按右方向键。
~
在 Normal 模式下按 ~ 键(翻转当前字母大小写)。
[
在 Insert 或 Replace 模式下按左方向键。
]
在 Insert 或 Replace 模式下按右方向键。
23
"断行设置
24 set lbr
25 set fo+=mB
26
"搜索时高亮显示被找到的文本。
27 set hls
28
" 带有如下符号的单词不要被换行分割
29 set iskeyword+=_,$,@,%,#,-
30

-------补充------
让vim 记住上次关闭时光标位置
Here's something for your <.vimrc> which will allow you to restore your cursor position in a file over several editing sessions.   This technique uses the viminfo option:

Ex. set viminfo='10,\"100,:20,%,n~/.viminfo
     au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif

If you're on Unix, the viminfo is probably fine as is (but check up on Vim's help for viminfo to see if you like the settings above).   For Windows you'll need to change the "n" suboption to something like

Ex. set viminfo='10,\"100,:20,%,nc:\\some\\place\\under\\Windoz\\_viminfo

This tip is a somewhat improved version of the example given for :he line()
in the Vim on-line documentation.


Windows下Vim的字体设置
想换一下vim的字体,默认的字体(Fixdays)看程序总觉得有点丑。上网找了一下,发现挺多这方面的。结果照着设置了一下,都没通过,得,自己看文档吧

切换命令模式,输入:

:h guifont

看了一下关于guifont的文档,发现网上看过的都是在Mac和Linux下的设置,也没指出来,误人那

在Windows下正确的设置如下:

set guifont=Consolas:h11

如果字体中间有空格的话,用下划线表示空格,如:

set guifont=Courier_New:h11

上面冒号后面表示选项,如h11表示字体高度11,宽度相应变大,效果就是字体大小变为11号了

还有其它的选项如宽度,字符集等等,自己可以看文档说明添加

ps:Linux,Mac下的设置也可以在文档中找到

vim配色方案
http://www.cs.cmu.edu/~maverick/VimColorSchemeTest/

posted @ 2009-01-18 17:37  艾阳君  阅读(171)  评论(0编辑  收藏  举报