(Remove html character entities) |
(Change <tt> to <code>, perhaps also minor tweak.) |
||
Line 3: | Line 3: | ||
|previous=886 |
|previous=886 |
||
|next=889 |
|next=889 |
||
− | |created= |
+ | |created=2005 |
|complexity=basic |
|complexity=basic |
||
|author=Tye Z |
|author=Tye Z |
||
Line 11: | Line 11: | ||
|category2= |
|category2= |
||
}} |
}} |
||
− | When starting Vim, you can open multiple files, one to a window or tab, with the < |
+ | When starting Vim, you can open multiple files, one to a window or tab, with the <code>-o</code>, <code>-O</code> or <code>-p</code> options. This tip discusses doing the same from within Vim. |
− | You can use a command like < |
+ | You can use a command like <code>:args *.c</code> to replace the argument list with all <code>.c</code> files, then display those files with a command like <code>:sall</code> (split window to show one file per window), or <code>:tab sall</code> (show one file per tab). |
Here is another method. Put the following in your [[vimrc]]: |
Here is another method. Put the following in your [[vimrc]]: |
||
Line 28: | Line 28: | ||
'''Customizations''' |
'''Customizations''' |
||
− | *If desired, substitute < |
+ | *If desired, substitute <code>--remote-tab-silent</code> in place of <code>--remote-silent</code> to load all the files in new tabs. |
*If running under Windows, you'll probably want to allow backslashes to occur in path names, like this: |
*If running under Windows, you'll probably want to allow backslashes to occur in path names, like this: |
||
<pre> |
<pre> |
||
Line 35: | Line 35: | ||
==Alternative== |
==Alternative== |
||
− | If you put the following code in your vimrc, you can simply do < |
+ | If you put the following code in your vimrc, you can simply do <code>:Etabs file list</code>, <code>:Ewindows file list</code> (horizontal windows), or <code>:Evwindows file list</code> (vertical windows). |
− | The commands can be abbreviated, and the function allows for file globbing, so doing something like < |
+ | The commands can be abbreviated, and the function allows for file globbing, so doing something like <code>:Et *.html</code> should work. You may even find yourself using one of these to [[VimTip1285|replace the :edit command]]! |
<pre> |
<pre> |
Revision as of 05:54, 13 July 2012
created 2005 · complexity basic · author Tye Z · version 6.0
When starting Vim, you can open multiple files, one to a window or tab, with the -o
, -O
or -p
options. This tip discusses doing the same from within Vim.
You can use a command like :args *.c
to replace the argument list with all .c
files, then display those files with a command like :sall
(split window to show one file per window), or :tab sall
(show one file per tab).
Here is another method. Put the following in your vimrc:
com! -complete=file -nargs=* Edit silent! exec "!vim --servername " . v:servername . " --remote-silent <args>"
This uses the shell to send remote commands to the current instance of Vim.
Then do something like this to edit multiple files:
:Edit .vim/colors/*
Customizations
- If desired, substitute
--remote-tab-silent
in place of--remote-silent
to load all the files in new tabs. - If running under Windows, you'll probably want to allow backslashes to occur in path names, like this:
com! -complete=file -nargs=* Edit silent! exec "!vim --servername " . v:servername . " --remote-silent ".escape(<q-args>,'\')
Alternative
If you put the following code in your vimrc, you can simply do :Etabs file list
, :Ewindows file list
(horizontal windows), or :Evwindows file list
(vertical windows).
The commands can be abbreviated, and the function allows for file globbing, so doing something like :Et *.html
should work. You may even find yourself using one of these to replace the :edit command!
command! -complete=file -nargs=+ Etabs call s:ETW('tabnew', <f-args>) command! -complete=file -nargs=+ Ewindows call s:ETW('new', <f-args>) command! -complete=file -nargs=+ Evwindows call s:ETW('vnew', <f-args>) function! s:ETW(what, ...) for f1 in a:000 let files = glob(f1) if files == '' execute a:what . ' ' . escape(f1, '\ "') else for f2 in split(files, "\n") execute a:what . ' ' . escape(f2, '\ "') endfor endif endfor endfunction
References
Comments
TO DO
- Use fnameescape(), especially in the method that uses the shell.
From VimTip1234 comments section, an alternate method:
You can load an arbitrary list of files with :args <pattern>, for instance:
Open all .c or .h files in the directory (and it's subdirectories) two directories up from the current directory:
- args ../../**/*.[ch]
The only caveat (and it's a major one) is that it's very slow.