Suppose you'd like to open all the files in your checkout folder under the /trunk subdirectory. Assume the files are called first.c second.r third.cpp. How can you open all the files into vim with a single command.
The obvious answer is the following
$ vim first.c second.r third.cpp
But can you do this more simply?
To select multiple files on Windows 10 from a folder, use the Shift key and select the first and last file at the ends of the entire range you want to select. To select multiple files on Windows 10 from your desktop, hold down the Ctrl key as you click on each file until all are selected.
Click the first file or folder, and then press and hold the Ctrl key. While holding Ctrl , click each of the other files or folders you want to select.
Click in the Shortcut key box on the Shortcut tab. Then press a keyboard key to set up a Ctrl + Alt shortcut for it. Click the Apply and OK buttons. Thereafter, press the Ctrl + Alt hotkey for the batch file to open its file list.
To edit all files in the current folder, use:
vim *
To edit all files in tabs, use:
vim -p *
To edit all files in horizontally split windows, use:
vim -o *
Sounds like you're on linux or some Unix variant. Using the asterisk gets you all files in the current folder:
$ vim *
In addition to the answers given above, I'd like to point out that you can also do that from inside vim itself using
:args *
which sets the arglist to be the name of the files in the directory, and then you can display them in tabs with :tab all
(or you can use :argdo tabe
).
The other answers will not work if you have subdirectories. If you need to open all files in all subdirectories you can use command substitution:
vim `find . -type f`
If you want to ignore files in subdirectories write:
vim `find . -type f -depth 1`
You can, of course, get as fancy as you want using the find
command.
Edit all files using a given pattern:
vim `find . -name "*your*pattern*here*"`
Super useful when I do this:
vim `find . -name "*.go"`
durum's answer is incomplete. To open all files in the directory without opening files in subdirectories, use this:
vim `find . -maxdepth 1 -type f`
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With