:iab <buffer> <expr> function CodeAbbr("function", "function
\<CR>
\<CR>endfunction
\<UP><TAB>
\<UP><ESC>$li <C-R>=Eatchar(\'\\m\\s\\<bar>\\r\')<CR>
\")
<M-x>
來map Alt+x, 其中x 為 a\~z, A\~Z, 0\~9, 還有一些特殊符號像.和/<F4>
在文件開頭添加作者、檔案資訊function! AddTitle()
call append(0,"\" Author: Huang Po-Hsuan <aben20807@gmail.com>")
call append(1,"\" Filename: ".expand("%:t"))
call append(2,"\" Last Modified: ".strftime("%Y-%m-%d %H:%M:%S"))
call append(3,"\" Vim: enc=utf-8")
call append(4,"")
endfunction
<M-/>
來註解或取消註解map <F5> :call CompileAndRun()<CR>
" save -> close ALE -> print date -> [execute] run -> open ALE
function! CompileAndRun()
" save only when changed
execute "up"
execute "ALEDisable"
if &filetype == 'markdown'
" markdown preview
try
" Stop before starting and handle exception
execute "MarkdownPreviewStop"
catch /^Vim:E492:/
execute "MarkdownPreview"
endtry
else
" echo date time
silent execute "!echo"
silent execute "!echo -e '\033[31m ╔══════════════════════════════╗' "
silent execute "!echo -n ' ║ '"
silent execute "!echo -n `date`"
silent execute "!echo ' ║ '"
silent execute "!echo -e '\033[31m ╚══════════════════════════════╝' \033[37m"
" detect file type
if &filetype == 'rust'
" execute "!rustc % && time ./%< && rm %<"
execute "!time cargo run"
elseif &filetype == 'c'
execute "!gcc -std=c11 % -o /tmp/a.out && time /tmp/a.out"
elseif &filetype == 'cpp'
execute "!g++ -std=c++11 % -o /tmp/a.out && time /tmp/a.out"
elseif &filetype == 'java'
execute "!javac -encoding utf-8 %"
execute "!time java %<"
elseif &filetype == 'sh'
:!%
elseif &filetype == 'python'
execute "!time python3 %"
else
redraw
echohl WarningMsg
echo strftime(" ❖ 不支援 ❖ ")
echohl NONE
endif
endif
execute "ALEEnable"
endfunction
<F7>
開關<F3>
開關顯示Plugin 'Yggdroot/indentLine'
let g:indentLine_setColors = 0
let g:indentLine_char = '┊'
nnoremap <F3> :IndentLinesToggle<CR>
<F2>
開關顯示nnoremap <F2> :set norelativenumber!<CR>:set nonumber!<CR>
:set number
:set relativenumber
let g:mkdp_path_to_chrome = "cygstart /chrome.lnk"
let g:mkdp_auto_start = 0
<vim5632@rainslide.net>
function RemoveTrailingWhitespace()
if &ft != "diff"
let b:curcol = col(".")
let b:curline = line(".")
silent! %s/\s\+$//
silent! %s/\(\s*\n\)\+\%$//
call cursor(b:curline, b:curcol)
endif
endfunction
autocmd BufWritePre * call RemoveTrailingWhitespace()
<M-s>x
: 在光標所在的單字左右加入x, 其中x 為 ' , " , ( , [ , { , <<M-s>x
: 在 visual mode 則在選取的左右加入n<M-s>x
: 加在包含光標以後 n 個單字, n 為整數<M-d>x
: 若有包在 x 裡面則刪除字元 x<M-f>xy
: 用 y 取代 x<C-t>
在分屏開啟終端機nnoremap <C-t> :ConqueTermVSplit bash<CR>
<M-t>
就會顯示現在時間function! DateAndTime()
redraw
echohl WarningMsg
echo strftime(" ❖ 現在時間 %H:%M ❖ ")
echohl NONE
endfunction
nnoremap <M-t> :call DateAndTime()<CR>