Executing vim commands without interactive mode
I need to execute vim commands on thousands of files without suffering from interactive mode slowness. I tried :
find ... | xargs vim '+set fileencoding=utf-8 | x'
and
for file in ... ; do vim '+set fileencoding=utf-8 | x' $file done
but it's too slow and I have warnings
Vim : Warning 开发者_运维知识库: Output is not to a terminal
Is it impossible to avoid interactive mode in vim ?
ps: I can otherwise use iconv, but it causes errors with files > 32 ko
iconv --from-code=ISO-8859-1 --to-code=UTF-8 $file -o $file
I would do:
find .... -print0 | xargs -0 vim -c 'argdo set fenc=utf8' -c 'wqa'
Filetype, syntax and indent plugins are probably what's slowing you down. These are specified in your ~/.vimrc with a line that looks typically like:
filetype plugin indent on
- You could try commenting that out, or
You can start Vim without your plugins and ~/.vimrc but staying in nocompatible mode by doing:
vim -Nu NONE
精彩评论