1 Star 0 Fork 1

kyle / 我的vimrc配置

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

说明

"去掉讨厌的有关vi一致性模式,避免以前版本的一些bug和局限
set nocompatible
filetype off
set number " 显示行号
syntax on " 高亮
"高亮搜索
set hlsearch
"设置折叠方式
"set flodmethod=indent

"高亮光标所在行列
set cursorcolumn
set cursorline
" 自定义高亮颜色
hi CursorLine   cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white
hi CursorColumn cterm=NONE ctermbg=darkred ctermfg=white guibg=darkred guifg=white

" vim使用自动对起,也就是把当前行的对起格式应用到下一行
set autoindent
" 第二行,依据上面的对起格式,智能的选择对起方式,对于类似C语言编
set smartindent

"nnore 非递归映射
"空格控制折叠
nnoremap <space> @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo')<CR>

"先映射逗号为 leader
let mapleader=','
let g:mapleader=','

"再映射逗号 +w 未保存
nnoremap <leader>w :w<cr>
inoremap <leader>w <Esc>:w<cr>

"vib 实现选中空格到空格
"nnoremap vib  f<space>,,lv;h

"vib 实现选中html 属性
nnoremap vib  f<space>,lvf";

"vis 实现选中php变量连字符
nnoremap vis  bbhf$ve

"自动补全
:inoremap ( ()<ESC>i
:inoremap ) <c-r>=ClosePair(')')<CR>
":inoremap { {<CR>}<ESC>O
":inoremap } <c-r>=ClosePair('}')<CR>
:inoremap [ []<ESC>i
:inoremap ] <c-r>=ClosePair(']')<CR>
:inoremap " ""<ESC>i
:inoremap ' ''<ESC>i

"下面是插件
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
"插件管理插件Vundle
Plugin 'VundleVim/Vundle.vim'
"目录树插件
Plugin 'preservim/nerdtree'
""将F2设置为开关NERDTree的快捷键
map <f2> :NERDTreeToggle<cr>
" 显示行号
let NERDTreeShowLineNumbers=1
" 防止出现 ^G 问题
let g:NERDTreeNodeDelimiter = "\u00a0"

" 是否显示隐藏文件
let NERDTreeShowHidden=1
"vim git操作插件
Plugin 'tpope/vim-fugitive'

call vundle#end()

"自动保存最后修改时间
function SetLastModifiedTimes()
	let line = getline(7)
	let newtime = "* @LastEditTime: ".strftime("%Y年%m月%d日 %H时%I分%S秒")
	let repl = substitute(line,".*$",newtime,"g")
	let res = search("@LastEditTime","w")
	if res
		call setline(7,repl)
	endif
endfunction
autocmd BufWrite *.php call SetLastModifiedTimes()


" 当新建 .h .c .hpp .cpp .mk .sh等文件时自动调用SetTitle 函数
autocmd BufNewFile *.[ch],*.hpp,*.cpp,Makefile,*.mk,*.sh,*.php,*.html exec ":call SetTitle()" 
" 加入注释 

"加入c cpp h hpp ch mk php 等文件注释
func SetComment()
	call setline(1,"/*================================================================") 
	call append(line("."),   "*   Copyright (C) ".strftime("%Y")." EdisonLiu_ All rights reserved.")
	call append(line(".")+1, "*   ") 
	call append(line(".")+2, "* @Author: 偻儸小卒[EdisonLiu_]") 
	call append(line(".")+3, "* @Date:".strftime("%Y年%m月%d日 %H时%I分%S秒"))
	call append(line(".")+4, "* @LastEditTime:".strftime("%Y年%m月%d日 %H时%I分%S秒"))
	call append(line(".")+5, "* @Description:") 
	call append(line(".")+6, "*")
	call append(line(".")+7, "================================================================*/") 
	call append(line(".")+8, "")
	call append(line(".")+9, "")
endfunc

"加入html注释
func SetHtmlComment()
	call setline(1,"<!--") 
	call append(line("."),   " Copyright (C) ".strftime("%Y")." EdisonLiu_ All rights reserved.")
	call append(line(".")+1, "   ") 
	call append(line(".")+2, " @Author: 偻儸小卒[EdisonLiu_] 747357766@qq.com") 
	call append(line(".")+3, " @Date:".strftime("%Y年%m月%d日 %H时%I分%S秒"))
	call append(line(".")+4, " @LastEditTime:".strftime("%Y年%m月%d日 %H时%I分%S秒"))
	call append(line(".")+5, " @Description:") 
	call append(line(".")+6, "")
	call append(line(".")+7, "-->") 
	call append(line(".")+8, "")
	call append(line(".")+9, "")
endfunc

" 加入sh,Makefile注释
func SetComment_sh()
	call setline(3, "#================================================================") 
	call setline(4, "#   Copyright (C) ".strftime("%Y")." EdisonLiu_ All rights reserved.")
	call setline(5, "#   ") 
	call setline(6, "#   @Author: 偻儸小卒[EdisonLiu_] 747357766@qq.com") 
	call setline(7, "#   @Date:".strftime("%Y年%m月%d日 %H时%I分%S秒"))
	call setline(8, "#   @LastEditTime:".strftime("%Y年%m月%d日 %H时%I分%S秒")) 
	call setline(9, "#   @Description:") 
	call setline(10, "#")
	call setline(11, "#================================================================")
	call setline(12, "")
	call setline(13, "")
endfunc 
" 定义函数SetTitle,自动插入文件头 
func SetTitle()
	if &filetype == 'make' 
		call setline(1,"") 
		call setline(2,"")
		call SetComment_sh()
 
	elseif &filetype == 'sh' 
		call setline(1,"#!/system/bin/sh") 
		call setline(2,"")
		call SetComment_sh()
	elseif &filetype == 'html'
		call setline(2,"")
		call SetHtmlComment()
	else
	     call SetComment()
	     if expand("%:e") == 'hpp' 
		  call append(line(".")+10, "#ifndef _".toupper(expand("%:t:r"))."_H") 
		  call append(line(".")+11, "#define _".toupper(expand("%:t:r"))."_H") 
		  call append(line(".")+12, "#ifdef __cplusplus") 
		  call append(line(".")+13, "extern \"C\"") 
		  call append(line(".")+14, "{") 
		  call append(line(".")+15, "#endif") 
		  call append(line(".")+16, "") 
		  call append(line(".")+17, "#ifdef __cplusplus") 
		  call append(line(".")+18, "}") 
		  call append(line(".")+19, "#endif") 
		  call append(line(".")+20, "#endif //".toupper(expand("%:t:r"))."_H") 
 
	     elseif expand("%:e") == 'h' 
	  	call append(line(".")+10, "#pragma once") 
	     elseif &filetype == 'c' 
	  	call append(line(".")+10,"#include \"".expand("%:t:r").".h\"") 
	     elseif &filetype == 'cpp' 
	  	call append(line(".")+10, "#include \"".expand("%:t:r").".h\"") 
             elseif expand("%:e") == 'php' 
		call setline(1,"<?php  ")
		call append(line("."),"/*================================================================")
	  	call append(line(".")+11, " ?>")
	     endif
	endif
endfunc
MIT License Copyright (c) 2020 偻儸小卒[EdisonLiu_] Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

我的vimrc 配置文件 展开 收起
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/qqphp/my_vimrc_configuration.git
git@gitee.com:qqphp/my_vimrc_configuration.git
qqphp
my_vimrc_configuration
我的vimrc配置
master

搜索帮助