niyue

Editing Ruby File in Vim

In programming on 12月 27, 2007 at 10:34 上午

在/usr/share/vim/vim70/filetype.vim(in MacOS X)中找到ruby类型的设置,为其增加不同的后缀,使得*.rb,*.rake等都识别为ruby代码进行语法高亮:

au BufNewFile,BufRead *.rb,*.rake,*.rbw,*.gemspec setf ruby

在.vimrc中设置以下内容,即可使得编辑*.rb和*.erb时tab缩进值为2,但是其他类型的文件仍然为4.

set expandtab ” To insert space characters whenever the tab key is pressed
set tabstop=4 ” To control the number of space characters that will be inserted when the tab key is pressed
set shiftwidth=4 ” To change the number of space characters inserted for indentation
set softtabstop=4 ” makes the spaces feel like real tabs
au BufRead,BufNewFile *.rb set expandtab
au BufRead,BufNewFile *.rb set tabstop=2
au BufRead,BufNewFile *.rb set shiftwidth=2
au BufRead,BufNewFile *.rb set softtabstop=2
au BufRead,BufNewFile *.erb set expandtab
au BufRead,BufNewFile *.erb set tabstop=2
au BufRead,BufNewFile *.erb set shiftwidth=2
au BufRead,BufNewFile *.erb set softtabstop=2

发表评论

Fill in your details below or click an icon to log in:

WordPress.com 徽标

您正在使用您的 WordPress.com 账号评论。 注销 /  更改 )

Twitter picture

您正在使用您的 Twitter 账号评论。 注销 /  更改 )

Facebook photo

您正在使用您的 Facebook 账号评论。 注销 /  更改 )

Connecting to %s

%d 博主赞过: