首页 > 代码库 > vim个性化设置
vim个性化设置
配置文件为/etc/vimrc,以下修改直接在配置文件下方追加就可以
自动添加注释,vim写.sh和.py文件的时候命令模式下按F4,可自动添加注释
map <F4> ms:call AddAuthor()<cr>‘S function AddAuthor() let n=1 while n < 11 let line = getline(n) if line=~‘[#]*\s*\*\s*\S*Last\s*modified\s*:\s*\S*.*$‘ call UpdateTitle() return endif let n = n + 1 endwhile if &filetype == ‘sh‘ call AddTitleForShell() elseif &filetype == ‘python‘ call AddTitleForPython() else call AddTitleForC() endif endfunction "" add comment for * function AddTitleForC() call append(0,"# **********************************************************") call append(1,"") call append(2,"# * Create time : ".strftime("%Y-%m-%d %H:%M")) call append(3,"# * Filename : ".expand("%:t")) call append(4,"") call append(5,"# **********************************************************") endfunction "" add comment for Python function AddTitleForPython() call append(0,"#!/usr/bin/env python") call append(1,"#coding:utf-8") call append(2,"") call append(3,"# **********************************************************") call append(4,"# * Author : pengyongshi") call append(5,"# * Email : 58217892@qq.com") call append(6,"# * Create time : ".strftime("%Y-%m-%d %H:%M")) call append(7,"# * Last modified : ".strftime("%Y-%m-%d %H:%M")) call append(8,"# * Filename : ".expand("%:t")) call append(9,"# * Description : ") call append(10,"# **********************************************************") echohl WarningMsg | echo "Successful in adding the copyright." | echohl None endfunction "" add conment for shell function AddTitleForShell() call append(0,"#!/bin/bash") call append(1,"# **********************************************************") call append(2,"# * Author : pengyongshi") call append(3,"# * Email : 58217892@qq.com") call append(4,"# * Create time : ".strftime("%Y-%m-%d %H:%M")) call append(5,"# * Last modified : ".strftime("%Y-%m-%d %H:%M")) call append(6,"# * Filename : ".expand("%:t")) call append(7,"# * Description : ") call append(8,"# **********************************************************") endfunction
3. 设置tab键为4格
set tabstop=4
4. 自动缩进
set autoindent set cindent
5. 统一缩进4格,默认是8格
set softtabstop=4 set shiftwidth=4
本文出自 “搁浅丶” 博客,请务必保留此出处http://yasar.blog.51cto.com/9120455/1875112
vim个性化设置
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。