29 votes
Accepted

Go to last file in vim

You can use :last. See :help :last for more details. You might be interested in the other commands around it for managing files in :args as well.
filbranden's user avatar
  • 28.8k
18 votes

Renumbering buffer list

"the buffer numbers get crazy" Tell me about it! By the end of the day I'm easy over 100 buffers. But luckily, as you can see in this animation, you have tab completion for buffer names. So, even ...
Bruno Bronosky's user avatar
14 votes
Accepted

How to do :Sex but with a vertical split?

What you're looking for is :Vexplore. From your question, it sounds like you started off knowing only about :Sexplore and understandably thought that that was the basic command for bringing up the ...
Mike Holt's user avatar
  • 278
13 votes

Open multiple files in tabs from Explore mode

From :h netrw-t: BROWSING WITH A NEW TAB netrw-t Normally one enters a file or directory using the <cr>. The "t" map allows one to open a new window holding the new directory ...
statox's user avatar
  • 49.8k
13 votes
Accepted

How to quit one file and simultaneously open another file in vim?

I don't think this can be done using a single command. You'll have to use a combination of commands: As statox suggested, delete the current buffer and open a new one: :bd | e filename Or rename ...
muru's user avatar
  • 24.9k
10 votes

How to pass current file name with a different path to the command line

Special characters (see :h cmdline-special) and filename modifiers (see :h filename-modifiers) are expanded on the command line, so: :diffsplit Path/to/other/directory/%:t
Sato Katsura's user avatar
  • 4,009
9 votes
Accepted

Open markdown filename under cursor like gf, and jump to the section?

This function is not thoroughly tested but it should provide a good enough bootstrap for your own experiments. In ~/.vim/after/ftplugin/markdown.vim: function! s:MDGoToSection() let raw_filename ...
romainl's user avatar
  • 40.6k
8 votes
Accepted

Spread already open files into split view

Here are a bunch of helpful commands for you: To open every buffer in a horizontal split: :sball To open every buffer in a vertical split: :vert sball You can do the same thing with tabs, e.g, to ...
DJMcMayhem's user avatar
  • 17.6k
8 votes

How can I open the next/previous file alphabetically?

My EditSimilar plugin has :EditPrevious and :EditNext, which go alphabetically through files in the current directory. There are also :EditMinus / :EditPlus for numbers in files, and other, generic :...
Ingo Karkat's user avatar
  • 17.8k
8 votes

How to show search results for all open buffers

Commands :bufdo and :vimgrepadd This answer is based on https://stackoverflow.com/a/11976158/1057593. However, I wanted add a few bits. Again the basic command is :bufdo vimgrepadd pattern % If your ...
Hotschke's user avatar
  • 4,750
8 votes
Accepted

How to set manually the alternate file

The alternate file is stored in a register, "#. Change you line to: let @#='/path/to/alternate/file' For more help see: :h registers :h quote# :h :let-@
Peter Rincker's user avatar
8 votes
Accepted

How to get the names of all open buffers?

I suppose by "open files" you mean active buffers (see :h windows-intro). That could be achieved with the command :ls a (use h-flag to get hidden buffers if needed). To pack it into a function you ...
Matt's user avatar
  • 20.7k
8 votes
Accepted

Open multiple files in custom split layout

You could try it like this: vim -c "lefta vsplit file2.txt|split file1.txt" file3.txt With the option -c you can specify commands that should be executed after the first file was loaded. So ...
Ralf's user avatar
  • 9,197
7 votes

How to open a file from active buffer into a split window?

You can do :2sbN or :sbN 2 to split the window and go to the 2 buffer. To split the window vertically, you can use :vert sbN 3 to go to buffer 3. An alternative solution is to use the :sp [+cmd] ...
Christian Brabandt's user avatar
7 votes

How can I open the next/previous file alphabetically?

if all your files have a similar extension (.txt, .c, .py), place them in a folder and cd then vim *.text, vim *.c, vim *.py All the files will get added to args list, open the list by :args to see ...
Ashok Arora's user avatar
7 votes

Open multiple files in custom split layout

Actually, you don’t need saved sessions for this; vim -S will happily accept any file containing vimscript. So, write some commands for your custom layout (stolen from the other answer) edit file3 ...
D. Ben Knoble's user avatar
  • 26.2k
7 votes
Accepted

Can I open a file using the index shown by ":scriptnames"?

Since Vim 8.1.553, you can simply supply a count to the scriptnames command to have it edited. So in your case, you can simply use: :25scriptnames or :scriptnames 25 to edit the zipPlugin.vim
Christian Brabandt's user avatar
7 votes
Accepted

The way to excute same command in command-line mode multiple times

Fill up the args list (:args …; note there are some nice shorthands so you don’t need to list out every file often) then use :argdo <cmd>. There is also :bufdo, :cdo, and more. This last is ...
D. Ben Knoble's user avatar
  • 26.2k
6 votes
Accepted

How to open a file from active buffer into a split window?

You can give :vsplit | buffer buffernumber/buffername to open a buffer in vertical split mode. Example: :split | buffer 3 Same applies to horizontal split mode too. You can use :sp as a shortcut ...
SibiCoder's user avatar
  • 3,372
6 votes
Accepted

"3 files to edit" after quit from editing multiple files in Vim

What's wrong with my editing process? Nothing. Vim likes to talk and, in fact, that message is written before you actually start editing your files, as can be confirmed if you issue gvim instead of ...
Quasímodo's user avatar
  • 2,466
5 votes

Open markdown filename under cursor like gf, and jump to the section?

As I said in the comments on my setup gf didn't opened the file because # was in isfname, so using set isfname-=# allowed gf to jump to the file. As I also said I think the feature to go to a section ...
statox's user avatar
  • 49.8k
5 votes

How can I open the next/previous file alphabetically?

Following up on my comment… I've created 1000 files named 1.txt to 1000.txt with the following command: $ touch {1..1000}.txt In Vim, I could use :args *.txt to load each of them in the argument ...
romainl's user avatar
  • 40.6k
5 votes
Accepted

navigating multiple files - arguments and buffers

The only system I know of that comes with the real vi by default is Arch Linux. In all the others, the vi command is some kind of "alias" that points to a more advanced vi clone like nvi or vim. So ...
romainl's user avatar
  • 40.6k
5 votes
Accepted

How to create multiple files?

You can create a bunch of filenamed buffers from within vim using :argadd: :argadd dir1/index.blade.php dir2/create.blade.php foo/show.blade.php You can also use the syntax :argadd dir/{foo,bar}....
Mass's user avatar
  • 14.1k
5 votes
Accepted

How can I easily open two similar files?

Some characters are special on Vim's command-line (see :h cmdline-special), including % which is automatically replaced by the path to the current file relative to the current working directory. Some ...
user938271's user avatar
  • 5,957
4 votes

How to open multiple files matching a wildcard expression?

This is definitely covered already in other answers, but tl;dr Open in buffers: :n <your-file-glob> Open in tabs: :n <your-file-glob> | tab all Open in windows: :n <your-file-glob> | ...
Chris's user avatar
  • 243
4 votes

How to open multiple files matching a wildcard expression?

To open matching files in separate tabs… :n */.git/config | tab all Explanation: :n (:next) sets the next-file list to all matches. tab all opens all files in the next-file list in new tabs. … or ...
Alex Quinn's user avatar
4 votes

How can I copy the current file and start editing the copy instead of the current file?

If you are working on a file that is not in the current working directory, and you want to save it under a new name in that directory, you can use the following: execute 'saveas' expand('%:h') . "...
Swoogan's user avatar
  • 141
4 votes
Accepted

Open multiple files in tabs from Explore mode

Let's Vim do it for you. You can put the following code at the end of your vimrc file: function! NetrwOpenMultiTab(current_line,...) range " Get the number of lines. let n_lines = a:lastline -...
Jair López's user avatar
  • 1,854
4 votes
Accepted

Is it possible to open multiple files at the end or at the first occurrence of a string?

One workaround would be to use :argdo (which runs an ex command in each file in the argument list): vim +"argdo norm G" file1 file2 vim +"argdo /searchPattern" file1 file2 You will be left in the ...
Rich's user avatar
  • 31.9k

Only top scored, non community-wiki answers of a minimum length are eligible