Someone at my workplace committed non-indented JavaScript I have the VIM plugin autoformat installed and want to run :Autoformat
on all .js files in my project directory, how would one do this?
1 Answer
If your project directory is just a regular directory you could use argdo
.
Navigate to the directory in your shell and open vim with vim ./.*
. This will open all the files in the directory in vim's argument list. Then you can simply do
:argdo Autoformat <BAR> update
See :help :argdo
for more info.
-
1You can also populate the arglist via
:args
. e.g.:args **/*.js
. You can also use backticks to execute a command to make this process quicker/better.:args `ag --js -g ''`
,:args `find . -type f -name '*.js'`
, or:args `git diff --name-only HEAD^..HEAD`
Jul 10, 2017 at 21:10