weixin_慕数据6599043
# 自动加入文件头, 编辑 vim /etc/vimrc 文件
autocmd BufNewFile *.py,*.sh, exec ":call SetTitle()"
let $author_name = "Hello"
let $author_mail = "Hello@163.com"
func SetTitle()
call setline(1, "\#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
call append(line("."), "\# FileName:".expend("%"))
call append(line(".")+1, "\# Author:".$author_name)
call append(line(".")+2, "\# Email:".$author_mail)
call append(line(".")+3, "\# CreateTime:".strftime("%C"))
call append(line(".")+4, "\#------------------------------------------------------------")
if &filetype == "sh"
call append(line(".")+5, "\# !/bin/bash")
else
call append(line(".")+5, "\# !/bin/python")
endif
call append(line(".")+6, "")
autocmd BufNewFile * normal G
小马_125
切换一个普通用户试下
醉李白
比较一下前后的代码有什么不同
醉李白
设置如果只对root用户无效的话,可以试试下面的方法:
(1)用vim命令编辑文件
(2)在~/.bashrc中添加alias vi=vim。
不期而遇TLJ
还有一点一定要记住,有可能/etc/vimrc不生效,一般情况的是在自己家目录下边的.vimrc这个文件才会生效!!!一定要注意!!!!!!!!!!
再见你
配置filetype on???
慕粉2247536793
文件类型啊
杰猛人
这根本就不全,你在网上搜下vim的配置 , 一大堆别人的配置,有的有详细的注释。
慕粉3321357
set number
set autoindent
set cindent
let $author_name="consoles"
let $author_email="consoles.me@gmail.com"
function! AutoSetShFileHead()
if &filetype == 'sh'
call setline(1, "\#!/bin/bash")
call append(line("."),"\# filename: ".expand("%"))
call append(line(".")+1,"\# author: ".$author_name)
call append(line(".")+2,"\# email: ".$author_email)
call append(line(".")+3,"\# created time: ".strftime("%c"))
endif
normal G
normal o
normal o
endfunc这个是我的vimrc文件,你可以参考下。我是按照这个教程设置的。
xyl5869
未名公子
自己创建一个就行了
慕粉tao222
自动将光标定位到末尾
weibo_曦儿yan_0
不用,chmod 755