Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 32b1310

Browse files
committed
Merge pull request ma6174#37 from androidyue/support_ruby
Auto add ruby hashbang when creating .rb files
2 parents c5826f4 + 509f3f8 commit 32b1310

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

.vimrc

+8-2
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ nmap tt :%s/\t/ /g<CR>
111111
"""""新文件标题
112112
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
113113
"新建.c,.h,.sh,.java文件,自动插入文件头
114-
autocmd BufNewFile *.cpp,*.[ch],*.sh,*.java,*.py exec ":call SetTitle()"
114+
autocmd BufNewFile *.cpp,*.[ch],*.sh,*.rb,*.java,*.py exec ":call SetTitle()"
115115
""定义函数SetTitle,自动插入文件头
116116
func SetTitle()
117117
"如果文件类型为.sh文件
@@ -121,7 +121,13 @@ func SetTitle()
121121
elseif &filetype == 'python'
122122
call setline(1,"#!/usr/bin/env python")
123123
call append(line("."),"# coding=utf-8")
124-
call append(line(".")+1, "")
124+
call append(line(".")+1, "")
125+
126+
elseif &filetype == 'ruby'
127+
call setline(1,"#!/usr/bin/env ruby")
128+
call append(line("."),"# encoding: utf-8")
129+
call append(line(".")+1, "")
130+
125131
" elseif &filetype == 'mkd'
126132
" call setline(1,"<head><meta charset=\"UTF-8\"></head>")
127133
else

0 commit comments

Comments
 (0)