function vimtoutf8(){
[ "$1" ] && file=$1 || return
cd "$wechatfiles"
vim -e ${file}<<-!
:set fenc=utf-8
:wq
!
file ${file}
}
这个函数写的我煞费苦心! 花了很大精力才尝试出来!
以后在命令行下直接借助各种函数封装vim的功能都可以了!
比如: set ff=dos/unix
一直没找到好的办法写出来bash下直接转换文件编码到utf-8.
之前好不容易写了一个函数借助于powershell的:
function isotoutf8(){
[ "$1" ] && urlfile=$1 || return
cd "$wechatfiles"
str='PowerShell -Command "& {get-content infile | set-content outfile -encoding utf8}" '
str=${str/infile/${urlfile}}
str=${str/outfile/${urlfile}.utf8}
eval "$str"
}