Open all files (including hidden ones) in vi

I have such a file structure

/foo/bar/ ├── .foo.cfg ├── foo.cfg ├── foo.data ├── foo.py ├── .svn │  ├── ... │  ├── ... │  └── ... ├── . └── .. 

I want to open all hidden and not hidden files in vim. I could do it manually so

 vi .foo.cfg foo.cfg foo.data foo.py 

but this does not work when there are 100+ files. I also tried the following without success

 #hidden files not loaded vi * #Includes folders and '.' and '..' vi * .* #loads files one at a time for i in `ls -a` ; do vi $i; done; #loads files one at a time find . -name "*" -type f -maxdepth 1 -exec vi {} ";" 
+4
source share
3 answers

The following should work:

 find . -maxdepth 1 -type f -exec vi {} + 

On the find man page:

  -exec command {} + 

This option -exec option runs the specified command in the selected files, but the command line is created by adding each name of the selected file at the end; the total number of command calls will be much less than the number of matching files. The command line is built in much the same way that xargs creates its command lines. Only one instance of {} is allowed per command. The command runs in the start directory.

+5
source

A simple solution would be

 vim $(find . -type f) 

note that this opens all the files in the current folder, doing the same for the files in the folders of the current folder. You can also try

 vim * .[^.]* 

it will not open . or .. because it does not match the pattern.

+3
source

Inside vim doing

 :args * .* **/{*,.*} 

should work like for example

 :args `find . -maxdepth 1 -type f` 

To work with your files there is also :argadd :argdel :argdo :rewind :next , etc.

0
source

Source: https://habr.com/ru/post/1384987/


All Articles