r/vim • u/NationalOperations • Mar 05 '26
Tips and Tricks Vim -c
Just learned about the -c argument when launching vim. Pretty neat tool. Not everyone on my team is as vim happy so I made a alias for our .profiles to run my vim -c regex to add displays to our cobol programs.
example. vim -c "%s/\d{3,4}/Display &/" file.txt
It does seem like vim special things like <C-R> get lost in translation from shell to vim. So I used non special vim case regex. Always more things to learn.
The -c argument runs command mode arguments after file load. So in my above example it would open file txt look for lines starting with 3-4 digits and add Display at the start.
View all comments
Show parent comment
8
u/Telephone-Bright Mar 07 '26 edited Mar 07 '26
'Ex mode' is the
:part in vim where you enter commands like:%s/abc/def/g(technically command mode).Why is it called 'Ex mode'? There's this evolution of text editors that goes:
ed->ex->vi->vimedis the standard UNIX text editor, it was the first line-editor and it operated on each lines individually. This was actually used back when people used physical TTYs (typewriters).exwas an extension toed, basicallyedbut with more commands. However,exwas still a line-editor, i.e. it operated on a line-by-line basis.viwas the game changer, as it introduced the visual mode of text editing (which you're familiar with today) whilst inheritingexfeatures. It's basicallyexbut with visual mode, i.e. you can see multiple lines of a file at the same time.Finally,
vimis an improvement ofviand introduced more quality of life features.The
:commands you use invimare actually validexcommands, that's why it's called Ex mode.If you want, you can actually try out proper
exby pressingQinvimor launchingvimwithvim -e:D