Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I open several files at once in Vim?

Tags:

vim

Is there a way to open all the files in a directory from within Vim? So a :command that would say in effect "Open all the files under /some/path into buffers".

Ideally, it would be great to open all the files under a dir recursively.

like image 979
Ethan Avatar asked Jan 07 '10 19:01

Ethan


People also ask

How do I open multiple files in Vim vertically?

Suppose you have opened a file on Vim editor and you want to split it vertically. To achieve this: Enter command mode by pressing the ESC button. Press the keyboard combination Ctrl + w , followed by the letter 'v' .

How do I open multiple tabs in Vim?

To directly move to first tab or last tab, you can enter the following in command mode: :tabfirst or :tablast for first or last tab respectively. To move back and forth : :tabn for next tab and :tabp for previous tab. You can list all the open tabs using : :tabs. To open multiple files in tabs: $ vim -p source.

How do I open multiple files in Linux?

Open multiple files and easily switch between them To switch from one tab to other, you can use the :bn and :bp commands while the editor is in the command mode. That's it.

Can you edit multiple files in Vim?

By default, Vim starts with a single window, which is enough for editing a single file. But sometimes, you may have to work on multiple files. Vim makes it easier to work with multiple files at once with its window management system, allowing you to work on multiple files at the same time within a single Vim session.


2 Answers

The command you are looking for is args:

For example:

:args /path_to_dir/* 

will open all files in the directory

like image 169
skinp Avatar answered Oct 24 '22 18:10

skinp


Why it doesn't work if I want to open all files ending with a certain extension? I tried

:n ./**.cs 

and opens only the files in the currenty directory.

I found the answer.The correct code is :n **/*.cs

For more information :h find

like image 35
mp. Avatar answered Oct 24 '22 19:10

mp.