# 我的vimrc配置 **Repository Path**: qqphp/my_vimrc_configuration ## Basic Information - **Project Name**: 我的vimrc配置 - **Description**: 我的vimrc 配置文件 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 1 - **Created**: 2021-05-16 - **Last Updated**: 2021-05-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## 说明 ```shell "去掉讨厌的有关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 @=((foldclosed(line('.')) < 0) ? 'zc' : 'zo') "先映射逗号为 leader let mapleader=',' let g:mapleader=',' "再映射逗号 +w 未保存 nnoremap w :w inoremap w :w "vib 实现选中空格到空格 "nnoremap vib f,,lv;h "vib 实现选中html 属性 nnoremap vib f,lvf"; "vis 实现选中php变量连字符 nnoremap vis bbhf$ve "自动补全 :inoremap ( ()i :inoremap ) =ClosePair(')') ":inoremap { {}O ":inoremap } =ClosePair('}') :inoremap [ []i :inoremap ] =ClosePair(']') :inoremap " ""i :inoremap ' ''i "下面是插件 set rtp+=~/.vim/bundle/Vundle.vim call vundle#begin() "插件管理插件Vundle Plugin 'VundleVim/Vundle.vim' "目录树插件 Plugin 'preservim/nerdtree' ""将F2设置为开关NERDTree的快捷键 map :NERDTreeToggle " 显示行号 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(".")+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,"") endif endif endfunc ```