【持续更新】Vim使用配置

前言

本配置文件仅供个人使用。
环境:Ubuntu 20.0.4/ win10 64bit Vim版本:2:8.0.1453-1ubuntu1.1

syntax on
set backspace=indent,eol,start
set nu
set tabstop=4
set shiftwidth=4
set cin
" colo delek
set mouse=a
set clipboard=unnamed
set viminfo='1000,<500
inoremap (      ()<ESC>i
inoremap [      []<ESC>i
inoremap {      {}<ESC>i
inoremap "      ""<ESC>i

set re=1
set ttyfast
set lazyredraw

if has('clipboard')
if has('unnamedplus') " When possible use + register for copy-paste
set clipboard=unnamed,unnamedplus
else " On mac and Windows, use * register for copy-paste
set clipboard=unnamed
endif
endif

"添加作者信息
map <F1> :call AddTitle()<CR>
function AddTitle()
    call append(0,"//Author       :    Baolar")
    call append(1,"//Last modified:	".strftime("%Y-%m-%d %H:%M"))
    call append(2,"//Email        :    [email protected]")
    call append(3,"//Filename     :    ".expand("%:t"))
    echohl WarningMsg | echo "Successful in adding copyright." | echohl None
endf
 
function UpdateTitle()
     normal m'
     execute '/Last modified/s@:.*$@\=strftime(":\t%Y-%m-%d %H:%M")@'
     normal ''
     normal mk
     execute '/Filename/s@:.*$@\=":\t".expand("%:t")@'
     execute "noh"
     normal 'k
     echohl WarningMsg | echo "Successful in updating the copyright." | echohl None
endfunction
function Title()
    let n = 1
    while n < 6
        let line = getline(n)
        if line =~ '^\s*\S*Last\smodified\S*.*$'
            call UpdateTitle()
            return
        endif
        let n = n + 1
    endwhile
    call AddTitle()
endfunction
 
 
 
 
"添加头文件
map <F5> :call HeadFile()<CR>
function HeadFile()
    call append(5,"#include <bits/stdc++.h>")
    call append(6,"using namespace std;")
    call append(7,"typedef long long ll;")
    call append(8,"const int mod = 1e9 + 7;")
    call append(9,"const int maxn = 1e5 + 5;")
	call append(10,"ll gcd(ll a, ll b) { if (!b) return a; return gcd(b, a % b);}")
	call append(11, "ll lcm(ll a, ll b) { return a * b / gcd(a, b);}")
	call append(12, "ll fpow(ll a, ll b, ll mod) { ll ans = 1 % mod; while (b) { if (b & 1) ans = ans * a % mod; a = a * a % mod; b >>= 1; } return ans;}")
	call append(13,"int main() {")
	call append(14,"    std::ios::sync_with_stdio(false);")
	call append(15,"    cin.tie(0), cout.tie(0);")
	call append(16,"")
	call append(17,"    return 0;")
	call append(18,"}")
    echohl WarningMsg | echo "Successful in adding copyright." | echohl None
endf
 


猜你喜欢

转载自blog.csdn.net/weixin_43269437/article/details/102943628