Issue
I want to run a vim command for example gg=G
but in the terminal.
I have tried vim gg=G filename
but it didn't work.
This would be useful as I normally work on gedit, but vim is very powerful, so would be cool to use some of its features without having to enter file in vim running the command and exiting vim, especially since exiting takes 14 contextually dependent instructions.
the other question with a similar name as this one, is about a different topic: How to run vim commands on vim it self. While this question is about runing vim command on a file
Solution
Vim can run commands perfectly the way I interpret your desires.
You simply use ex +"<command>" <filename>
or vim -c "<command>" <filename>
, they are equivalent.
Try running the following:
$ ex +"norm gg=G" +"wq" <filename>
It will open your file, filter the whole file with the first command and save it (overwriting) with the wq
command.
Answered By - Roger Answer Checked By - David Marino (WPSolving Volunteer)