作为码农无法接受中文标点,遂一怒之下写了个vim脚本,一键替换中文标点为英文标点.
将下面的代码拷贝到你的vimrc,在normal mode下按下Ctrl + S,完成替换.
(中途参照了cold night的代码)
-
"ctrl-s将中文标点换为英文标点
-
function! ChangeChineseMark()
-
if search(\'。\')
-
execute \"1,$s/。/\\./g\"
-
endif
-
-
if search(\',\')
-
execute \"1,$s/,/,/g\"
-
endif
-
-
if search(\';\')
-
execute \"1,$s/;/,/g\"
-
endif
-
-
if search(\'?\')
-
execute \"1,$s/?/?/g\"
-
endif
-
-
if search(\':\')
-
execute \"1,$s/:/\\:/g\"
-
endif
-
-
if search(\'‘\')
-
execute \"1,$s/‘/\\\'/g\"
-
endif
-
-
if search(\'’\')
-
execute \"1,$s/’/\\\'/g\"
-
endif
-
-
if search(\'”\')
-
execute \"1,$s/”/\\\"/g\"
-
endif
-
-
if search(\'“\')
-
execute \"1,$s/“/\\\"/g\"
-
endif
-
-
if search(\'《\')
-
execute \"1,$s/《/\\
-
endif
-
-
if search(\'》\')
-
execute \"1,$s/》/\\>/g\"
-
endif
-
-
if search(\'—\')
-
execute \"1,$s/——/-/g\"
-
endif
-
-
if search(\')\')
-
execute \"1,$s/)/\\)/g\"
-
endif
-
-
if search(\'(\')
-
execute \"1,$s/(/\\(/g\"
-
endif
-
-
if search(\'…\')
-
execute \"1,$s/……/^/g\"
-
endif
-
-
if search(\'¥\')
-
execute \"1,$s/¥/$/g\"
-
endif
-
-
if search(\'!\')
-
execute \"1,$s/!/!/g\"
-
endif
-
-
if search(\'·\')
-
execute \"1,$s/·/`/g\"
-
endif
-
-
if search(\'、\')
-
execute \"1,$s/、/,/g\"
-
endif
-
endfunction
-
noremap :call ChangeChineseMark()
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30156807/viewspace-1657810/
,如需转载,请注明出处,否则将追究法律责任。