跳到正文

剪贴板

剪贴板 st3oka2x

原文
剪贴板信息

剪贴板信息

收录
更新

Windows:

C++
" This is configuration about cursor left
nmap <left> <BS>
vmap <left> <BS>
smap <left> <C-G><BS><C-G>

" This is configuration about cursor right
nmap <right> <Space>
vmap <right> <Space>
smap <right> <C-G><Space><C-G>

" This is configuration about up and down on select mode
smap <up> <C-G>k<C-G>
smap <down> <C-G>j<C-G>

" This is configuration about parenthesis matching
imap ( ()<ESC>i
imap { {}<ESC>i
imap [ []<ESC>i
func QuotationMarks(ch)
    if(getline('.')[col('.')-2] == '\')
        return a:ch
    else
        return a:ch . a:ch . "\<ESC>i"
endfunc
inoremap " <C-R>=QuotationMarks('"')<CR>
inoremap ' <C-R>=QuotationMarks("'")<CR>
func DeleteBoth()
	if(getline('.')[col('.')-2] == '(' && getline('.')[col('.')-1] == ')')||(getline('.')[col('.')-2] == '[' && getline('.')[col('.')-1] == ']') || (getline('.')[col('.')-2] == '"' && getline('.')[col('.')-1] == '"' && getline('.')[col('.')-3] != '\') ||(getline('.')[col('.')-2] == "'" && getline('.')[col('.')-1] == "'" && getline('.')[col('.')-3] != '\') || (getline('.')[col('.')-2] == '{' && getline('.')[col('.')-1] == '}')
		return "\<ESC>2s"
	else
		return "\<BS>"
	endif
endfunc
inoremap <BS> <C-R>=DeleteBoth()<CR>
func EnterBoth()
    if (getline('.')[col('.') - 2] == '{' && getline('.')[col('.') - 1] == '}')
        return "\<CR>\<up>\<right>\<CR>"
    else
        return "\<CR>"
    endif
endfunc
inoremap <CR> <C-R>=EnterBoth()<CR>

" This is configuration about head text
nmap R :set ft=cpp<CR>,a<C-G>#include<bits/stdc++.h><CR>using namespace std;<CR>#define int long long<CR><CR>signed main(<ESC>la<CR>{<CR>return 0;<ESC>ka<CR>
vmap R <ESC>:set ft=cpp<CR>,a<C-G>#include<bits/stdc++.h><CR>using namespace std;<CR>#define int long long<CR><CR><CR><CR>signed main(<ESC>la<CR>{<CR>return 0;<ESC>kkkki
imap <ESC> <ESC>:call Save()<CR>
nmap <F11> :call CompileRunGcc()<CR>
imap <F11> <C-O>:call CompileRunGcc()<CR>
vmap <F11> <ESC>:call CompileRunGcc()<CR>v
smap <F11> <C-G>:call CompileRunGcc()<CR><C-G>

nmap ,st :e D:\Vim\_vimrc<CR>

nmap ,a ggVG
nmap ,w :w<CR>
nmap ,e :e<CR>
nmap ,be :browse confirm e<CR>
nmap ,tn :tabnew<CR>
nmap ,th :tabprev<CR>
nmap ,tl :tabnext<CR>
nmap ,tc :tabclose<CR>
nmap ,sc :set ft=cpp<CR>
nmap ,sp :set ft=python<CR>
nmap ,h <Home>
nmap ,ll <End>
nmap ,k <PageUp>
nmap ,j <PageDown>
nmap ,la :bp<CR>
nmap ,dq :1<CR>
nmap ,dh :$<CR>
nmap ,sw :call Save()<CR>:so %<CR>

nmap <C-C> msggyG`s
nmap <ESC> :noh<CR>

imap `ll long long
imap `it int
imap `ull unsigned long long
imap `ui unsigned
imap `si signed
imap `db double
imap `ot float
imap `128i __int128
imap `str string
imap `ve vector
imap `f for(
imap `w while(
imap `if if(
imap `ot cout<<
imap `in cin>>
imap `xs fixed<<setprecision(
imap `do do<CR>{<CR><ESC>lawhile(<ESC>la;<ESC>O
imap `ve vector<><ESC>i
imap `sta stack<><ESC>i
imap `q queue<><ESC>i
imap `pq priority_queue<><ESC>i
imap `bi bitset<><ESC>i
imap `se set<><ESC>i
imap `mse muitiset<><ESC>i
imap `mp map<><ESC>i
imap `mmp muitimap<><ESC>i
imap `at auto<><ESC>i
imap `il inline
imap `re register
imap `co const
imap `bo bool
imap `vo void
imap `uc struct
imap `cl class
imap `op operator
imap `ed return ;<ESC>i
imap `pu public:<ESC><<A
imap `pr private:<ESC><<A
imap ``o <ESC>o
imap ``p <ESC>O

imap ``k <ESC>ddkkpa
nmap ,dk ddkkp
imap ``j <ESC>ddpa
nmap ,dj ddp

" echom

" Vim with all enhancements
source $VIMRUNTIME/vimrc_example.vim

source D:/Vim/annotation.vim

" Remap a few keys for Windows behavior
" source $VIMRUNTIME/mswin.vim

" Mouse behavior (the Windows way)
behave mswin
set relativenumber
set number
set cursorline
set ts=4
set sts=4
set sw=4
set et
set guifont=consolas:h20
set clipboard=unnamed
set timeoutlen=100000
func! CompileRunGcc()
    exec "call Save()"
    if &filetype == 'c'
        exec "!gcc \"%\" -o \"%<\"&&\"%<\""
    elseif &filetype == 'cpp'
        exec "!g++ -std=c++14 \"%\" -o \"%<\"&&\"%<\""
    elseif &filetype == 'python'
        exec "!py \"%\""
    endif
endfunc

func Save()
    let s = expand('%:t')
    if s != ''
        exec "w!"
    endif
endfunc
" Use the internal diff if available.
" Otherwise use the special 'diffexpr' for Windows.
if &diffopt !~# 'internal'
  set diffexpr=MyDiff()
endif

function MyDiff()
  let opt = '-a --binary '
  if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
  if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
  let arg1 = v:fname_in
  if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
  let arg1 = substitute(arg1, '!', '\!', 'g')
  let arg2 = v:fname_new
  if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
  let arg2 = substitute(arg2, '!', '\!', 'g')
  let arg3 = v:fname_out
  if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
  let arg3 = substitute(arg3, '!', '\!', 'g')
  if $VIMRUNTIME =~ ' '
    if &sh =~ '\<cmd'
      if empty(&shellxquote)
        let l:shxq_sav = ''
        set shellxquote&
      endif
      let cmd = '"' . $VIMRUNTIME . '\diff"'
    else
      let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
    endif
  else
    let cmd = $VIMRUNTIME . '\diff'
  endif
  let cmd = substitute(cmd, '!', '\!', 'g')
  silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
  if exists('l:shxq_sav')
    let &shellxquote=l:shxq_sav
  endif
endfunction

Ubuntu:

C++
nmap <C-Q> :quit<CR>
imap <C-Q> <ESC>:quit<CR>
vmap <C-Q> <ESC>:quit<CR>
nmap <C-N> :tabnew<CR>
imap <C-N> <ESC>:tabnew<CR>a
vmap <C-N> <ESC>:tabnew<CR>
nmap <C-S-C> :set ft=cpp<CR>
imap <C-S-C> <ESC>:set ft=cpp<CR>a
vmap <C-S-C> <ESC>:set ft=cpp<CR>v
nmap <C-S-P> :set ft=python<CR>
imap <C-S-P> <ESC>:set ft=python<CR>a
vmap <C-S-P> <ESC>:set ft=python<CR>v
nmap <C-O> :browse confirm e<CR>
imap <C-O> <ESC>:browse confirm e<CR>a
vmap <C-O> <ESC>:browse confirm e<CR>v
nnoremap i :set norelativenumber<CR>i
nnoremap I :set norelativenumber<CR>I
nnoremap a :set norelativenumber<CR>a
nnoremap A :set norelativenumber<CR>A
nnoremap s :set norelativenumber<CR>s
nnoremap S :set norelativenumber<CR>S
nnoremap o :set norelativenumber<CR>o
nnoremap O :set norelativenumber<CR>O
nnoremap <Insert> :set norelativenumber<CR><Insert>
imap ( ()<ESC>i
imap { {}<ESC>i
imap [ []<ESC>i
inoremap " ""<ESC>i
inoremap ' ''<ESC>i
nmap R :set ft=cpp<CR>,a<C-G>#include<bits/stdc++.h><CR>using namespace std;<CR>#define int long long<CR><CR>signed main(<ESC>la<CR>{<CR><ESC>ka<CR>return 0;<ESC>ka<CR>
vmap R <ESC>:set ft=cpp<CR>,a<C-G>#include<bits/stdc++.h><CR>using namespace std;<CR>#define int long long<CR><CR><CR><CR>signed main(<ESC>la<CR>{<CR><ESC>ka<CR>return 0;<ESC>kkkki
imap <ESC> <ESC>:call Save()<CR>:set relativenumber<CR>
nmap <F11> :call CompileRunGcc()<CR>
imap <F11> <ESC>:call CompileRunGcc()<CR>i
vmap <F11> <ESC>:call CompileRunGcc()<CR>v
smap <F11> <C-G>:call CompileRunGcc()<CR><C-S-G>

nmap ; :
nmap ,a ggVG
nmap ,w :w<CR>
nmap ,e :e<CR>
nmap ,be :browse confirm e<CR>
nmap ,tn :tabnew<CR>
nmap ,th :tabprev<CR>
nmap ,tl :tabnext<CR>
nmap ,tc :tabclose<CR>
nmap ,sc :set ft=cpp<CR>
nmap ,sp :set ft=python<CR>
nmap ,h <Home>
nmap ,ll <End>
nmap ,k <PageUp>
nmap ,j <PageDown>
nmap ,la :bp<CR>
nmap ,dq :1<CR>
nmap ,dh :$<CR>
nmap ,sw :call Save()<CR>:so %<CR>
imap `ll long long
imap `it int
imap `ull unsigned long long
imap `ui unsigned
imap `si signed
imap `db double
imap `ot float
imap `128i __int128
imap `str string
imap `ve vector
imap `f for(
imap `w while(
imap `if if(
imap `ot cout<<
imap `in cin>>
imap `xs fixed<<setprecision(
imap `do do<CR>{<CR><ESC>lawhile(<ESC>la;<ESC>O
imap `ve vector<><ESC>i
imap `sta stack<><ESC>i
imap `q queue<><ESC>i
imap `pq priority_queue<><ESC>i
imap `bi bitset<><ESC>i
imap `se set<><ESC>i
imap `mse muitiset<><ESC>i
imap `mp map<><ESC>i
imap `mmp muitimap<><ESC>i
imap `at auto<><ESC>i
imap `il inline
imap `re register
imap `co const
imap `bo bool
imap `vo void
imap `uc struct
imap `cl class
imap `op operator
imap `ed return ;<ESC>i
imap `pu public:<ESC><<a
imap `pr private:<ESC><<a
imap ``o <ESC>o
imap ``p <ESC>O

imap ``k <ESC>ddkkpa
nmap ,dk ddkkp
imap ``j <ESC>ddpa
nmap ,dj ddp

" echom

set mouse=a
set relativenumber
set number
set cursorline
set ts=4
set sts=4
set sw=4
set et
set guifont=Hack\ 15
set clipboard=unnamed
func! CompileRunGcc()
    exec "call Save()"
    if &filetype == 'c'
        exec "!gcc \"%\" -o \"%<\"&&\"%<\""
    elseif &filetype == 'cpp'
        exec "!g++ -std=c++14 \"%\" -o \"%<\"&&./\"%<\""
    elseif &filetype == 'python'
        exec "!py \"%\""
    endif
endfunc

func Save()
    let s = expand('%:t')
    if s == ''
        exec "w!"
    else
        exec "w!"
    endif
endfunc

" Use the internal diff if available.
" Otherwise use the special 'diffexpr' for Windows.
if &diffopt !~# 'internal'
  set diffexpr=MyDiff()
endif

function MyDiff()
  let opt = '-a --binary '
  if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
  if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
  let arg1 = v:fname_in
  if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
  let arg1 = substitute(arg1, '!', '\!', 'g')
  let arg2 = v:fname_new
  if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
  let arg2 = substitute(arg2, '!', '\!', 'g')
  let arg3 = v:fname_out
  if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
  let arg3 = substitute(arg3, '!', '\!', 'g')
  if $VIMRUNTIME =~ ' '
    if &sh =~ '\<cmd'
      if empty(&shellxquote)
        let l:shxq_sav = ''
        set shellxquote&
      endif
      let cmd = '"' . $VIMRUNTIME . '\diff"'
    else
      let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
    endif
  else
    let cmd = $VIMRUNTIME . '\diff'
  endif
  let cmd = substitute(cmd, '!', '\!', 'g')
  silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
  if exists('l:shxq_sav')
    let &shellxquote=l:shxq_sav
  endif
endfunction
func DeleteBoth()
	if (getline('.')[col('.') - 2] == '(' && getline('.')[col('.') - 1] == ')')||(getline('.')[col('.') - 2] == '[' && getline('.')[col('.') - 1] == ']') || (getline('.')[col('.') - 2] == '"' && getline('.')[col('.') - 1] == '"') ||(getline('.')[col('.') - 2] == "'" && getline('.')[col('.') - 1] == "'") || (getline('.')[col('.') - 2] == '{' && getline('.')[col('.') - 1] == '}')
		return "\<ESC>2s"
	else
		return "\<BS>"
	endif
endfunc
inoremap <BS> <C-R>=DeleteBoth()<CR>

func EnterBoth()
    if (getline('.')[col('.') - 2] == '{' && getline('.')[col('.') - 1] == '}')
        return "\<CR>\<up>\<right>\<CR>\<tab>"
    else
        return "\<CR>"
    endif
endfunc

inoremap <CR> <C-R>=EnterBoth()<CR>