<p>I've started using Vim to develop Perl scripts and am starting to find it very powerful. </p>

<p>One thing I like is to be able to open multiple files at once with:</p>

<pre><code>vi main.pl maintenance.pl
</code></pre>

<p>and then hop between them with:</p>

<pre><code>:n
:prev
</code></pre>

<p>and see which file are open with:</p>

<pre><code>:args
</code></pre>

<p>And to add a file, I can say: </p>

<pre><code>:n test.pl
</code></pre>

<p>which I expect would then be added to my list of files, but instead it wipes out my current file list and when I type <code>:args</code> I only have <code>test.pl</code> open.</p>

<p>So how can I add and remove files in my args list?</p>

[{'answer_id': 53667, 'author': 'Konrad Rudolph', 'author_id': 1968, 'author_profile': 'https://Stackoverflow.com/users/1968', 'pm_score': 5, 'selected': False, 'text': '<p>Vim (but not the original Vi!) has tabs which I find (in many contexts) superior to buffers. You can say <code>:tabe [filename]</code> to open a file in a new tab. Cycling between tabs is done by clicking on the tab or by the key combinations [<em>n</em>]<code>gt</code> and <code>gT</code>. Graphical Vim even has graphical tabs.</p>\n'}, {'answer_id': 53668, 'author': 'fijter', 'author_id': 3215, 'author_profile': 'https://Stackoverflow.com/users/3215', 'pm_score': 11, 'selected': True, 'text': "<p>Why not use tabs (introduced in Vim 7)?\nYou can switch between tabs with <code>:tabn</code> and <code>:tabp</code>,\nWith <code>:tabe &lt;filepath&gt;</code> you can add a new tab; and with a regular <code>:q</code> or <code>:wq</code> you close a tab.\nIf you map <code>:tabn</code> and <code>:tabp</code> to your <kbd>F7</kbd>/<kbd>F8</kbd> keys you can easily switch between files.</p>\n\n<p>If there are not that many files or you don't have Vim 7 you can also split your screen in multiple files: <code>:sp &lt;filepath&gt;</code>. Then you can switch between splitscreens with <kbd>Ctrl</kbd>+<kbd>W</kbd> and then an arrow key in the direction you want to move (or instead of arrow keys, <kbd>w</kbd> for next and <kbd>W</kbd> for previous splitscreen)</p>\n"}, {'answer_id': 53701, 'author': 'MarkB', 'author_id': 2996, 'author_profile': 'https://Stackoverflow.com/users/2996', 'pm_score': 7, 'selected': False, 'text': '<p>To add to the <code>args</code> list:</p>\n\n<pre><code>:argadd\n</code></pre>\n\n<p>To delete from the <code>args</code> list:</p>\n\n<pre><code>:argdelete\n</code></pre>\n\n<p>In your example, you could use <code>:argedit</code> test.pl to add test.pl to the <code>args</code> list and edit the file in one step.</p>\n\n<p><code>:help args</code> gives much more detail and advanced usage</p>\n'}, {'answer_id': 53702, 'author': 'Rob Wells', 'author_id': 2974, 'author_profile': 'https://Stackoverflow.com/users/2974', 'pm_score': 6, 'selected': False, 'text': '<p>I think you may be using the wrong command for looking at the list of files that you have open.</p>\n\n<p>Try doing an <code>:ls</code> to see the list of files that you have open and you\'ll see:</p>\n\n<pre><code>   1 %a   "./checkin.pl"            line 1\n  2 #    "./grabakamailogs.pl"     line 1\n  3      "./grabwmlogs.pl"         line 0\n  etc.\n</code></pre>\n\n<p>You can then bounce through the files by referring to them by the numbers listed, e.g.\n:3b</p>\n\n<p>or you can split your screen by entering the number but using sb instead of just b.</p>\n\n<p>As an aside % refers to the file currently visible and # refers to the alternate file.</p>\n\n<p>You can easily toggle between these two files by pressing <kbd>Ctrl</kbd> <kbd>Shift</kbd> <kbd>6</kbd></p>\n\n<p>Edit: like <code>:ls</code> you can use <code>:reg</code> to see the current contents of your registers including the 0-9 registers that contain what you\'ve deleted. This is especially useful if you want to reuse some text that you\'ve previously deleted.</p>\n'}, {'answer_id': 53709, 'author': 'Andy Whitfield', 'author_id': 4805, 'author_profile': 'https://Stackoverflow.com/users/4805', 'pm_score': 6, 'selected': False, 'text': '<p>I use buffer commands - <code>:bn</code> (next buffer), <code>:bp</code> (previous buffer) <code>:buffers</code> (list open buffers) <code>:b&lt;n&gt;</code> (open buffer n) <code>:bd</code> (delete buffer). <code>:e &lt;filename&gt;</code> will just open into a new buffer.</p>\n'}, {'answer_id': 53714, 'author': 'Sébastien RoccaSerra', 'author_id': 2797, 'author_profile': 'https://Stackoverflow.com/users/2797', 'pm_score': 9, 'selected': False, 'text': "<h3>Listing</h3>\n\n<p>To see a list of current buffers, I use:</p>\n\n<pre><code>:ls\n</code></pre>\n\n<hr>\n\n<h3>Opening</h3>\n\n<p>To open a new file, I use</p>\n\n<pre><code>:e ../myFile.pl\n</code></pre>\n\n<p>with enhanced tab completion (put <code>set wildmenu</code> in your <code>.vimrc</code>).</p>\n\n<p>Note: you can also use <code>:find</code> which will search a set of paths for you, but you need to customize those paths first.</p>\n\n<hr>\n\n<h3>Switching</h3>\n\n<p>To switch between all open files, I use</p>\n\n<pre><code>:b myfile\n</code></pre>\n\n<p>with enhanced tab completion (still <code>set wildmenu</code>).</p>\n\n<p>Note: <code>:b#</code> chooses the last visited file, so you can use it to switch quickly between two files.</p>\n\n<hr>\n\n<h3>Using windows</h3>\n\n<p><code>Ctrl-W s</code> and <code>Ctrl-W v</code> to split the current window horizontally and vertically. You can also use <code>:split</code> and <code>:vertical split</code> (<code>:sp</code> and <code>:vs</code>)</p>\n\n<p><code>Ctrl-W w</code> to switch between open windows, and <code>Ctrl-W h</code> (or <code>j</code> or <code>k</code> or <code>l</code>) to navigate through open windows.</p>\n\n<p><code>Ctrl-W c</code> to close the current window, and <code>Ctrl-W o</code> to close all windows except the current one.</p>\n\n<p>Starting vim with a <code>-o</code> or <code>-O</code> flag opens each file in its own split.</p>\n\n<hr>\n\n<p>With all these I don't need tabs in Vim, and my fingers find my buffers, not my eyes.</p>\n\n<p>Note: if you want all files to go to the same instance of Vim, start Vim with the <code>--remote-silent</code> option.</p>\n"}, {'answer_id': 63489, 'author': 'indentation', 'author_id': 7706, 'author_profile': 'https://Stackoverflow.com/users/7706', 'pm_score': 3, 'selected': False, 'text': '<p>If you are going to use multiple buffers, I think the most important thing is to\nset hidden\nso that it will let you switch buffers even if you have unsaved changes in the one you are leaving.</p>\n'}, {'answer_id': 64829, 'author': 'zigdon', 'author_id': 4913, 'author_profile': 'https://Stackoverflow.com/users/4913', 'pm_score': 4, 'selected': False, 'text': '<p>When using multiple files in vim, I use these commands mostly (with ~350 files open):</p>\n\n<ul>\n<li><code>:b &lt;partial filename&gt;&lt;tab&gt;</code> (jump to a buffer)</li>\n<li><code>:bw</code> (buffer wipe, remove a buffer)</li>\n<li><code>:e &lt;file path&gt;</code> (edit, open a new buffer></li>\n<li><code>pltags</code> - enable jumping to subroutine/method definitions</li>\n</ul>\n'}, {'answer_id': 65732, 'author': 'shyam', 'author_id': 7616, 'author_profile': 'https://Stackoverflow.com/users/7616', 'pm_score': 8, 'selected': False, 'text': "<pre><code>:ls\n</code></pre>\n\n<p>for list of open buffers</p>\n\n<ul>\n<li><code>:bp</code> previous buffer</li>\n<li><code>:bn</code> next buffer</li>\n<li><code>:bn</code> (<code>n</code> a number) move to n'th buffer</li>\n<li><code>:b &lt;filename-part&gt;</code> with tab-key providing auto-completion (awesome !!)</li>\n</ul>\n\n<p>In some versions of vim, <code>bn</code> and <code>bp</code> are actually <code>bnext</code> and <code>bprevious</code> respectively. Tab auto-complete is helpful in this case.</p>\n\n<p>Or when you are in normal mode, use <code>^</code> to switch to the last file you were working on.</p>\n\n<p>Plus, you can save sessions of vim</p>\n\n<pre><code>:mksession! ~/today.ses\n</code></pre>\n\n<p>The above command saves the current open file buffers and settings to <code>~/today.ses</code>. You can load that session by using</p>\n\n<pre><code>vim -S ~/today.ses\n</code></pre>\n\n<p>No hassle remembering where you left off yesterday. ;)</p>\n"}, {'answer_id': 75793, 'author': 'projecktzero', 'author_id': 13380, 'author_profile': 'https://Stackoverflow.com/users/13380', 'pm_score': 2, 'selected': False, 'text': '<p>I use multiple buffers that are set hidden in my <code>~/.vimrc</code> file.</p>\n\n<p>The mini-buffer explorer script is nice too to get a nice compact listing of your buffers. Then <code>:b1</code> or <code>:b2</code>... to go to the appropriate buffer or use the mini-buffer explorer and tab through the buffers.</p>\n'}, {'answer_id': 83984, 'author': 'Max Cantor', 'author_id': 16034, 'author_profile': 'https://Stackoverflow.com/users/16034', 'pm_score': 4, 'selected': False, 'text': '<p>I use the same .vimrc file for gVim and the command line Vim.  I tend to use tabs in gVim and buffers in the command line Vim, so I have my .vimrc set up to make working with both of them easier:</p>\n\n<pre><code>" Movement between tabs OR buffers\nnnoremap L :call MyNext()&lt;CR&gt;\nnnoremap H :call MyPrev()&lt;CR&gt;\n\n" MyNext() and MyPrev(): Movement between tabs OR buffers\nfunction! MyNext()\n    if exists( \'*tabpagenr\' ) &amp;&amp; tabpagenr(\'$\') != 1\n        " Tab support &amp;&amp; tabs open\n        normal gt\n    else\n        " No tab support, or no tabs open\n        execute ":bnext"\n    endif\nendfunction\nfunction! MyPrev()\n    if exists( \'*tabpagenr\' ) &amp;&amp; tabpagenr(\'$\') != \'1\'\n        " Tab support &amp;&amp; tabs open\n        normal gT\n    else\n        " No tab support, or no tabs open\n        execute ":bprev"\n    endif\nendfunction\n</code></pre>\n\n<p>This clobbers the existing mappings for <kbd>H</kbd> and <kbd>L</kbd>, but it makes switching between files extremely fast and easy.  Just hit <kbd>H</kbd> for next and <kbd>L</kbd> for previous; whether you\'re using tabs or buffers, you\'ll get the intended results.</p>\n'}, {'answer_id': 8436685, 'author': 'puk', 'author_id': 654789, 'author_profile': 'https://Stackoverflow.com/users/654789', 'pm_score': 5, 'selected': False, 'text': '<p>Things like <code>:e</code> and <code>:badd</code> will only accept ONE argument, therefore the following will fail</p>\n\n<pre><code>:e foo.txt bar.txt\n:e /foo/bar/*.txt\n:badd /foo/bar/*\n</code></pre>\n\n<p>If you want to add multiple files from within vim, use <code>arga[dd]</code></p>\n\n<pre><code>:arga foo.txt bar.txt\n:arga /foo/bar/*.txt\n:argadd /foo/bar/*\n</code></pre>\n'}, {'answer_id': 16854181, 'author': 'Cpt. Senkfuss', 'author_id': 1823536, 'author_profile': 'https://Stackoverflow.com/users/1823536', 'pm_score': 0, 'selected': False, 'text': '<p>if you\'re on osx and want to be able to click on your tabs, use MouseTerm and SIMBL (taken from <a href="http://ayaz.wordpress.com/2010/10/19/using-mouse-inside-vim-on-terminal-app/" rel="nofollow noreferrer">here</a>). Also, check out this <a href="https://stackoverflow.com/questions/1727261/scrolling-inside-vim-in-macs-terminal?rq=1">related discussion</a>.</p>\n'}, {'answer_id': 17536403, 'author': 'user2179522', 'author_id': 2179522, 'author_profile': 'https://Stackoverflow.com/users/2179522', 'pm_score': 4, 'selected': False, 'text': '<p>You may want to use <a href="http://vim.wikia.com/wiki/Using_marks" rel="noreferrer">Vim global marks</a>.</p>\n\n<p>This way you can quickly bounce between files, and even to the marked location in the file.  Also, the key commands are short:\n   <code>\'C</code>  takes me to the code I\'m working with,\n   <code>\'T</code>  takes me to the unit test I\'m working with.</p>\n\n<p>When you change places, resetting the marks is quick too:\n   <code>mC</code>  marks the new code spot,\n   <code>mT</code>  marks the new test spot.</p>\n'}, {'answer_id': 20964867, 'author': 'user2663398', 'author_id': 2663398, 'author_profile': 'https://Stackoverflow.com/users/2663398', 'pm_score': 2, 'selected': False, 'text': '<p>have a try following maps for convenience editing multiple files</p>\n\n<p>" split windows</p>\n\n<p><code>nmap &lt;leader&gt;sh :leftabove  vnew&lt;CR&gt;</code></p>\n\n<p><code>nmap &lt;leader&gt;sl :rightbelow vnew&lt;CR&gt;</code></p>\n\n<p><code>nmap &lt;leader&gt;sk :leftabove  new&lt;CR&gt;</code></p>\n\n<p><code>nmap &lt;leader&gt;sj :rightbelow new&lt;CR&gt;</code></p>\n\n<p>" moving around</p>\n\n<p><code>nmap &lt;C-j&gt; &lt;C-w&gt;j</code></p>\n\n<p><code>nmap &lt;C-k&gt; &lt;C-w&gt;k</code></p>\n\n<p><code>nmap &lt;C-l&gt; &lt;C-w&gt;l</code></p>\n\n<p><code>nmap &lt;C-h&gt; &lt;C-w&gt;h</code></p>\n'}, {'answer_id': 21220765, 'author': 'Michael Durrant', 'author_id': 631619, 'author_profile': 'https://Stackoverflow.com/users/631619', 'pm_score': 3, 'selected': False, 'text': '<p>My way to effectively work with multiple files is to use tmux.</p>\n\n<p>It allows you to split windows vertically and horizontally, as in:</p>\n\n<p><img src="https://i.stack.imgur.com/XDnTX.png" alt="enter image description here"></p>\n\n<p>I have it working this way on both my mac and linux machines and I find it better than the native window pane switching mechanism that\'s provided (on Macs).  I find the switching easier and only with tmux have I been able to get the \'new page at the same current directory\' working on my mac (despite the fact that there seems to be options to open new panes in the same directory) which is a surprisingly critical piece.  An instant new pane at the current location is amazingly useful.  A method that does new panes with the same key combos for both OS\'s is critical for me and a bonus for all for future personal compatibility.\nAside from multiple tmux panes, I\'ve also tried using multiple tabs, e.g. <img src="https://i.stack.imgur.com/O0N8A.png" alt="enter image description here"> and multiple new windows, e.g. <img src="https://i.stack.imgur.com/TpErK.png" alt="enter image description here"> and ultimately I\'ve found that multiple tmux panes to be the most useful for me.  I am very \'visual\' and like to keep my various contexts right in front of me, connected together as panes.  </p>\n\n<p>tmux also support horizontal and vertical panes which the older <code>screen</code> didn\'t (though mac\'s iterm2 seems to support it, but again, the current directory setting didn\'t work for me). tmux 1.8 </p>\n'}, {'answer_id': 24555993, 'author': 'Jens', 'author_id': 925649, 'author_profile': 'https://Stackoverflow.com/users/925649', 'pm_score': 2, 'selected': False, 'text': '<p>I use the command line and git a lot, so I have this alias in my bashrc:</p>\n\n<pre><code>alias gvim="gvim --servername \\$(git rev-parse --show-toplevel || echo \'default\') --remote-tab"\n</code></pre>\n\n<p>This will open each new file in a new tab on an existing window and will create one window for each git repository.\nSo if you open two files from repo A, and 3 files from repo B, you will end up with two windows, one for repo A with two tabs and one for repo B with three tabs.</p>\n\n<p>If the file you are opening is not contained in a git repo it will go to a default window.</p>\n\n<p>To jump between tabs I use these mappings:</p>\n\n<pre><code>nmap &lt;C-p&gt; :tabprevious&lt;CR&gt;\nnmap &lt;C-n&gt; :tabnext&lt;CR&gt;\n</code></pre>\n\n<p>To open multiple files at once you should combine this with one of the other solutions.</p>\n'}, {'answer_id': 29597152, 'author': 'superarts.org', 'author_id': 772295, 'author_profile': 'https://Stackoverflow.com/users/772295', 'pm_score': 1, 'selected': False, 'text': "<p>When I started using VIM I didn't realize that tabs were supposed to be used as different window layouts, and buffer serves the role for multiple file editing / switching between each other. Actually in the beginning tabs are not even there before v7.0 and I just opened one VIM inside a terminal tab (I was using gnome-terminal at the moment), and switch between tabs using alt+numbers, since I thought using commands like :buffers, :bn and :bp were too much for me. When VIM 7.0 was released I find it's easier to manager a lot of files and switched to it, but recently I just realized that buffers should always be the way to go, unless one thing: you need to configure it to make it works right.</p>\n\n<p>So I tried vim-airline and enabled the visual on-top tab-like buffer bar, but graphic was having problem with my iTerm2, so I tried a couple of others and it seems that MBE works the best for me. I also set shift+h/l as shortcuts, since the original ones (moving to the head/tail of the current page) is not very useful to me.<br>\n<br>\n<code>map &lt;S-h&gt; :bprev&lt;Return&gt;</code>\n<br>\n<code>map &lt;S-l&gt; :bnext&lt;Return&gt;</code></p>\n\n<p>It seems to be even easier than gt and gT, and :e is easier than :tabnew too. I find :bd is not as convenient as :q though (MBE is having some problem with it) but I can live with all files in buffer I think.</p>\n"}, {'answer_id': 30915769, 'author': 'Andrew', 'author_id': 1977609, 'author_profile': 'https://Stackoverflow.com/users/1977609', 'pm_score': 5, 'selected': False, 'text': '<p>Some answers in this thread suggest using tabs and others suggest using buffer to accomplish the same thing. Tabs and Buffers are different. I strongly suggest you read this article "<a href="https://joshldavis.com/2014/04/05/vim-tab-madness-buffers-vs-tabs/" rel="noreferrer">Vim Tab madness - Buffers vs Tabs</a>".</p>\n\n<p>Here\'s a nice summary I pulled from the article:</p>\n\n<p>Summary:</p>\n\n<ul>\n<li>A buffer is the in-memory text of a file.</li>\n<li>A window is a viewport on a buffer.</li>\n<li>A tab page is a collection of windows.</li>\n</ul>\n'}, {'answer_id': 34109581, 'author': 'fede1024', 'author_id': 1025899, 'author_profile': 'https://Stackoverflow.com/users/1025899', 'pm_score': 2, 'selected': False, 'text': '<p>I made a <a href="https://www.youtube.com/watch?v=baNUGVAoX8M" rel="nofollow">very simple video</a> showing the workflow that I use. Basically I use the <a href="https://github.com/kien/ctrlp.vim" rel="nofollow">Ctrl-P</a> Vim plugin, and I mapped the buffer navigation to the Enter key.</p>\n\n<p>In this way I can press Enter in normal mode, look at the list of open files (that shows up in a small new window at the bottom of the screen), select the file I want to edit and press Enter again. To quickly search through multiple open files, just type part of the file name, select the file and press Enter.</p>\n\n<p>I don\'t have many files open in the video, but it becomes incredibly helpful when you start having a lot of them.</p>\n\n<p>Since the plugin sorts the buffers using a MRU ordering, you can just press Enter twice and jump to the most recent file you were editing.</p>\n\n<p>After the plugin is installed, the only configuration you need is:</p>\n\n<pre><code>nmap &lt;CR&gt; :CtrlPBuffer&lt;CR&gt;\n</code></pre>\n\n<p>Of course you can map it to a different key, but I find the mapping to enter to be very handy.</p>\n'}, {'answer_id': 35669509, 'author': 'Dionysis', 'author_id': 1236333, 'author_profile': 'https://Stackoverflow.com/users/1236333', 'pm_score': 1, 'selected': False, 'text': '<p>Most of the answers in this thread are using plain vim commands which is of course fine but I thought I would provide an extensive answer using a combination of plugins and functions that I find particularly useful (at least some of these tips came from <a href="https://www.destroyallsoftware.com/file-navigation-in-vim.html" rel="nofollow">Gary Bernhardt\'s file navigation tips</a>):</p>\n\n<ol>\n<li><p>To toggle between the last two file just press <code>&lt;leader&gt;</code> twice. I recommend assigning <code>&lt;leader&gt;</code> to the spacebar:</p>\n\n<pre><code>nnoremap &lt;leader&gt;&lt;leader&gt; &lt;c-^&gt;\n</code></pre></li>\n<li><p>For quickly moving around a project the answer is a fuzzy matching solution such as <a href="https://github.com/ctrlpvim/ctrlp.vim" rel="nofollow">CtrlP</a>. I bind it to <code>&lt;leader&gt;a</code> for quick access.</p></li>\n<li><p>In the case I want to see a visual representation of the currently open buffers I use <a href="https://github.com/jlanzarotta/bufexplorer" rel="nofollow">the BufExplorer plugin</a>. Simple but effective.</p></li>\n<li><p>If I want to browse around the file system I would use the command line or an external utility (Quicklsilver, Afred etc.) but to look at the current project structure <a href="https://github.com/scrooloose/nerdtree" rel="nofollow">NERD Tree</a> is a classic. Do not use this though in the place of <code>2</code> as your main file finding method. It will really slow you down. I use the binding <code>&lt;leader&gt;ff</code>.</p></li>\n</ol>\n\n<p>These should be enough for finding and opening files. From there of course use horizontal and vertical splits. Concerning splits I find these functions particularly useful:</p>\n\n<ol>\n<li><p>Open new splits in smaller areas when there is not enough room and expand them on navigation. Refer <a href="https://www.destroyallsoftware.com/file-navigation-in-vim.html" rel="nofollow">here</a> for comments on what these do exactly:</p>\n\n<pre><code>set winwidth=84\nset winheight=5\nset winminheight=5\nset winheight=999\n\nnnoremap &lt;C-w&gt;v :111vs&lt;CR&gt;\nnnoremap &lt;C-w&gt;s :rightbelow split&lt;CR&gt;\nset splitright\n</code></pre></li>\n<li><p>Move from split to split easily:</p>\n\n<pre><code>nnoremap &lt;C-J&gt; &lt;C-W&gt;&lt;C-J&gt;\nnnoremap &lt;C-K&gt; &lt;C-W&gt;&lt;C-K&gt;\nnnoremap &lt;C-L&gt; &lt;C-W&gt;&lt;C-L&gt;\nnnoremap &lt;C-H&gt; &lt;C-W&gt;&lt;C-H&gt;\n</code></pre></li>\n</ol>\n'}, {'answer_id': 36332558, 'author': 'Petur Subev', 'author_id': 332124, 'author_profile': 'https://Stackoverflow.com/users/332124', 'pm_score': 5, 'selected': False, 'text': '<p>Many answers here! What I use without reinventing the wheel - the most famous plugins (that are not going to die any time soon and are used by many people) to be ultra fast and geeky.</p>\n\n<ul>\n<li><strong>ctrlpvim/ctrlp.vim</strong> - to find file by name fuzzy search by its location or just its name</li>\n<li><strong>jlanzarotta/bufexplorer</strong> - to browse opened buffers (when you do not remember how many files you opened and modified recently and you do not remember where they are, probably because you searched for them with Ag)</li>\n<li><strong>rking/ag.vim</strong> to search the files with respect to gitignore</li>\n<li><strong>scrooloose/nerdtree</strong> to see the directory structure, lookaround, add/delete/modify files</li>\n</ul>\n\n<p><strong>EDIT:</strong> Recently I have been using <strong>dyng/ctrlsf.vim</strong>  to search with contextual view (like Sublime search) and I switched the engine from <strong>ag</strong> to <strong>ripgrep</strong>. The performance is outstanding.</p>\n\n<p><strong>EDIT2:</strong> Along with <strong>CtrlSF</strong> you can use <strong>mg979/vim-visual-multi</strong>, make changes to multiple files at once and then at the end save them in one go.</p>\n'}, {'answer_id': 44647932, 'author': 'qeatzy', 'author_id': 3625404, 'author_profile': 'https://Stackoverflow.com/users/3625404', 'pm_score': 4, 'selected': False, 'text': '<p>If <strong>using only vim built-in commands</strong>, the best one that I ever saw to switch among multiple buffers is this:</p>\n\n<pre><code>nnoremap &lt;Leader&gt;f :set nomore&lt;Bar&gt;:ls&lt;Bar&gt;:set more&lt;CR&gt;:b&lt;Space&gt;\n</code></pre>\n\n<p><strong>It perfectly combines both <code>:ls</code> and <code>:b</code> commands -- listing all opened buffers and waiting for you to input the command to switch buffer.</strong></p>\n\n<p>Given above mapping in vimrc, once you type <code>&lt;Leader&gt;f</code>,</p>\n\n<ul>\n<li>All opened buffers are displayed</li>\n<li>You can:\n\n<ul>\n<li>Type <code>23</code> to go to buffer 23,</li>\n<li>Type <code>#</code> to go to the alternative/MRU buffer,</li>\n<li>Type partial name of file, then type <code>&lt;Tab&gt;</code>, or <code>&lt;C-i&gt;</code> to autocomplete,</li>\n<li>Or just <code>&lt;CR&gt;</code> or <code>&lt;Esc&gt;</code> to stay on current buffer</li>\n</ul></li>\n</ul>\n\n<p>A snapshot of output for the above key mapping is:</p>\n\n<pre><code>:set nomore|:ls|:set more\n  1  h    "script.py"    line 1\n  2 #h  + "file1.txt"    line 6  -- \'#\' for alternative buffer\n  3 %a    "README.md"    line 17 -- \'%\' for current buffer\n  4       "file3.txt"    line 0  -- line 0 for hasn\'t switched to\n  5     + "/etc/passwd"  line 42 -- \'+\' for modified\n:b \'&lt;Cursor&gt; here\'\n</code></pre>\n\n<p>In the above snapshot:</p>\n\n<ul>\n<li>Second column: <code>%a</code> for current, <code>h</code> for hidden, <code>#</code> for previous, empty for hasn\'t been switched to.</li>\n<li>Third column: <code>+</code> for modified.</li>\n</ul>\n\n<p>Also, I strongly suggest <code>set hidden</code>. See <code>:help \'hidden\'</code>.</p>\n'}, {'answer_id': 44935024, 'author': 'dlmeetei', 'author_id': 1389898, 'author_profile': 'https://Stackoverflow.com/users/1389898', 'pm_score': 4, 'selected': False, 'text': "<p>To change all buffers to <code>tab</code> view.</p>\n<pre><code> :tab sball\n</code></pre>\n<p>will open all the buffers to tab view. Then we can use any tab related commands</p>\n<pre><code>gt or :tabn           &quot;    go to next tab\ngT or :tabp or :tabN  &quot;    go to previous tab\n</code></pre>\n<p>details at <code>:help tab-page-commands</code>.</p>\n<p>We can instruct vim to open ,as tab view, multiple files by <code>vim -p file1 file2</code>.\n<code>alias vim='vim -p'</code> will be useful.<br />\nThe same thing can also be achieved by having following autocommand in <code>~/.vimrc</code></p>\n<pre><code> au VimEnter * if !&amp;diff | tab all | tabfirst | endif\n</code></pre>\n<hr />\n<p>Anyway to answer the question:\nTo add to arg list: <code>arga file</code>,</p>\n<p>To delete from arg list: <code>argd pattern</code></p>\n<p>More at <code>:help arglist</code></p>\n"}, {'answer_id': 45770452, 'author': 'icc97', 'author_id': 327074, 'author_profile': 'https://Stackoverflow.com/users/327074', 'pm_score': 3, 'selected': False, 'text': '<p>I use the following, this gives you lots of features that you\'d expect to have in other editors such as Sublime Text / Textmate</p>\n\n<ol>\n<li>Use buffers not \'tab pages\'. Buffers are the same concept as tabs in almost all other editors.</li>\n<li>If you want the same look of having tabs you can use the <a href="https://github.com/vim-airline/vim-airline" rel="noreferrer">vim-airline</a> plugin with the following setting in your <code>.vimrc</code>: <code>let g:airline#extensions#tabline#enabled = 1</code>. This automatically displays all the buffers as tab headers when you have no tab pages opened</li>\n<li>Use Tim Pope\'s <a href="https://github.com/tpope/vim-unimpaired" rel="noreferrer">vim-unimpaired</a> which gives <kbd>[</kbd><kbd>b</kbd> and <kbd>]</kbd><kbd>b</kbd> for moving to previous/next buffers respectively (plus a whole host of other goodies)</li>\n<li>Have <code>set wildmenu</code> in your <code>.vimrc</code> then when you type <code>:b &lt;file part&gt;</code> + <kbd>Tab</kbd> for a buffer you will get a list of possible buffers that you can use left/right arrows to scroll through</li>\n<li>Use Tim Pope\'s <a href="https://github.com/tpope/vim-obsession" rel="noreferrer">vim-obsession</a> plugin to store sessions that play nicely with airline (I had <a href="https://github.com/vim-airline/vim-airline/issues/1505#issuecomment-316848122" rel="noreferrer">lots of pain with sessions and plugins</a>)</li>\n<li>Use Tim Pope\'s <a href="https://github.com/tpope/vim-vinegar" rel="noreferrer">vim-vinegar</a> plugin. This works with the native <code>:Explore</code> but makes it much easier to work with. You just type <code>-</code> to open the explorer, which is the same key as to go up a directory in the explorer. Makes navigating faster (however with fzf I rarely use this)</li>\n<li><a href="https://github.com/junegunn/fzf#as-vim-plugin" rel="noreferrer">fzf</a> (which can be installed as a vim plugin) is also a really powerful fuzzy finder that you can use for searching for files (and buffers too). fzf also <a href="https://github.com/junegunn/fzf#tips" rel="noreferrer">plays very nicely</a> with fd (a faster version of find)</li>\n<li>Use <a href="https://github.com/BurntSushi/ripgrep" rel="noreferrer">Ripgrep</a> with <a href="https://github.com/jremmen/vim-ripgrep" rel="noreferrer">vim-ripgrep</a> to search through your code base and then you can use <code>:cdo</code> on the results to do search and replace</li>\n</ol>\n'}, {'answer_id': 46858244, 'author': 'npit', 'author_id': 3532255, 'author_profile': 'https://Stackoverflow.com/users/3532255', 'pm_score': 0, 'selected': False, 'text': '<p>You can be an <em>absolute madman</em> and alias <code>vim</code> to <code>vim -p</code> by adding in your <code>.bashrc</code>:</p>\n<pre><code>alias vim=&quot;vim -p&quot;\n</code></pre>\n<p>This will result in opening multiple files from the shell in tabs, without having to invoke <code>:tab ball</code> from within vim afterwards.</p>\n'}, {'answer_id': 50671995, 'author': 'thenakulchawla', 'author_id': 4057016, 'author_profile': 'https://Stackoverflow.com/users/4057016', 'pm_score': 2, 'selected': False, 'text': '<p>I would suggest using the plugin </p>\n\n<blockquote>\n  <p>NERDtree</p>\n</blockquote>\n\n<p>Here is the github link with instructions.</p>\n\n<p><a href="https://github.com/scrooloose/nerdtree" rel="nofollow noreferrer">Nerdtree</a></p>\n\n<p>I use vim-plug as a plugin manager, but you can use Vundle as well.</p>\n\n<p><a href="https://github.com/junegunn/vim-plug" rel="nofollow noreferrer">vim-plug</a></p>\n\n<p><a href="https://github.com/VundleVim/Vundle.vim" rel="nofollow noreferrer">Vundle</a></p>\n'}, {'answer_id': 59810540, 'author': 'Mou Sam Dahal', 'author_id': 10048518, 'author_profile': 'https://Stackoverflow.com/users/10048518', 'pm_score': 3, 'selected': False, 'text': '<p>In my and other many vim users, the best option is to,</p>\n<ul>\n<li>Open the file using,</li>\n</ul>\n<blockquote>\n<p>:e file_name.extension</p>\n</blockquote>\n<p>And then just <kbd>Ctrl</kbd> + <kbd>6</kbd> to change to the last buffer. Or, you can always press</p>\n<blockquote>\n<p>:ls to list the buffer and then change the buffer using b followed by the buffer number.</p>\n</blockquote>\n<ul>\n<li>We make a vertical or horizontal split using</li>\n</ul>\n<blockquote>\n<p>:vsp for vertical split</p>\n<p>:sp for horizantal split</p>\n</blockquote>\n<p>And then <code>&lt;C-W&gt;&lt;C-H/K/L/j&gt;</code> to change the working split.</p>\n<p><strong>You can ofcourse edit any file in any number of splits.</strong></p>\n'}, {'answer_id': 66870832, 'author': 'Aram Simonyan', 'author_id': 14274837, 'author_profile': 'https://Stackoverflow.com/users/14274837', 'pm_score': 0, 'selected': False, 'text': '<ol>\n<li><p>To open 2 or more files with vim type: <code>vim -p file1 file2</code></p>\n</li>\n<li><p>After that command to go threw that files you can use <kbd>CTRL</kbd>+<kbd>Shift</kbd>+<kbd>↑</kbd> or <kbd>↓</kbd> , it will change your files in vim.</p>\n</li>\n<li><p>If u want to add one more file vim and work on it use: <code>:tabnew file3</code></p>\n</li>\n<li><p>Also u can use which will not create a new tab and will open file on screen slicing your screen: <code>:new file3</code></p>\n</li>\n<li><p>If u want to use a plugin that will help u work with directories\nand files i suggest u <a href="https://github.com/scrooloose/nerdtree" rel="nofollow noreferrer">NERDTree</a>.</p>\n</li>\n<li><p>To download it u need to have vim-plug so to download other plugins also NERDTree to type this commands in your <code>~/.vimrc</code>.</p>\n</li>\n</ol>\n<pre><code>    let data_dir = has(\'nvim\') ? stdpath(\'data\') . \'/site\' : \'~/.vim\'\n    if empty(glob(data_dir . \'/autoload/plug.vim\'))\n      silent execute \'!curl -fLo \'.data_dir.\'/autoload/plug.vim --create-dirs \n      https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim\'\n      autocmd VimEnter * PlugInstall --sync | source $MYVIMRC\n    endif\n\n    call plug#begin(\'~/.vim/plugged\')\n    Plug \'scrooloose/nerdtree\'\n    call plug#end()\n</code></pre>\n<ol start="7">\n<li>Then save .vimrc via command <code>:wq</code> , get back to it and type: <code>:PlugInstall</code></li>\n</ol>\n<p>After that the plugins will be installed and u could use your NERDTree with other plugins.</p>\n'}]
['https://Stackoverflow.com/questions/53664', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/4639/']