|
5 | 5 | <link href="https://learnbyexample.github.io/atom.xml" rel="self" type="application/atom+xml"/>
|
6 | 6 | <link href="https://learnbyexample.github.io"/>
|
7 | 7 | <generator uri="https://www.getzola.org/">Zola</generator>
|
8 |
| - <updated>2022-12-14T00:00:00+00:00</updated> |
| 8 | + <updated>2022-12-20T00:00:00+00:00</updated> |
9 | 9 | <id>https://learnbyexample.github.io/atom.xml</id>
|
| 10 | + <entry xml:lang="en"> |
| 11 | + <title>Vim tip 19: working with buffers</title> |
| 12 | + <published>2022-12-20T00:00:00+00:00</published> |
| 13 | + <updated>2022-12-20T00:00:00+00:00</updated> |
| 14 | + <link rel="alternate" href="https://learnbyexample.github.io/tips/vim-tip-19/" type="text/html"/> |
| 15 | + <id>https://learnbyexample.github.io/tips/vim-tip-19/</id> |
| 16 | + <content type="html"><p>Multiple files can be opened in Vim within the same tab page and/or in different tabs. From <a href="https://vimhelp.org/windows.txt.html#windows-intro">:h windows-intro</a>:</p> |
| 17 | +<blockquote> |
| 18 | +<ul> |
| 19 | +<li>A buffer is the in-memory text of a file.</li> |
| 20 | +<li>A window is a viewport on a buffer.</li> |
| 21 | +<li>A tab page is a collection of windows.</li> |
| 22 | +</ul> |
| 23 | +</blockquote> |
| 24 | +<ul> |
| 25 | +<li><kbd>:e</kbd> refreshes the current buffer (<code>:e</code> is short for <code>:edit</code>)</li> |
| 26 | +<li><kbd>:e filename</kbd> open a particular file by its path, in the same window</li> |
| 27 | +<li><kbd>:e #</kbd> switch back to the previous buffer, won't work if that buffer is not named</li> |
| 28 | +<li><kbd>Ctrl</kbd>+<kbd>6</kbd> switch back to the previous buffer, works even if that buffer is not named |
| 29 | +<ul> |
| 30 | +<li><kbd>Ctrl</kbd>+<kbd>^</kbd> can also be used</li> |
| 31 | +</ul> |
| 32 | +</li> |
| 33 | +<li><kbd>:e #1</kbd> open the first buffer, and so on</li> |
| 34 | +<li><kbd>:buffers</kbd> show all buffers |
| 35 | +<ul> |
| 36 | +<li><kbd>:ls</kbd> or <kbd>:files</kbd> can also be used</li> |
| 37 | +</ul> |
| 38 | +</li> |
| 39 | +<li><kbd>:bn</kbd> open the next file in the buffer list (<code>:bn</code> is short for <code>:bnext</code>) |
| 40 | +<ul> |
| 41 | +<li>opens the first buffer if you are on the last buffer</li> |
| 42 | +</ul> |
| 43 | +</li> |
| 44 | +<li><kbd>:bp</kbd> open the previous file in the buffer list (<code>:bp</code> is short for <code>:bprevious</code>) |
| 45 | +<ul> |
| 46 | +<li>opens the last buffer if you are on the first buffer</li> |
| 47 | +</ul> |
| 48 | +</li> |
| 49 | +</ul> |
| 50 | +<p><img src="/images/info.svg" alt="info" /> Use <kbd>:set hidden</kbd> if you want to switch to another buffer even if there are unsaved changes in the current buffer. Instead of this setting, you can also use <kbd>:hide edit filename</kbd> to hide the current unsaved buffer. You'll still get an error if you try to quit Vim without saving such buffers, unless you use the <code>!</code> modifier.</p> |
| 51 | +<p><img src="/images/info.svg" alt="info" /> See <a href="https://vimhelp.org/options.txt.html#%27autowrite%27">:h 'autowrite'</a> option if you want to automatically save changes when moving to another buffer.</p> |
| 52 | +<p><img src="/images/info.svg" alt="info" /> See <a href="https://vimhelp.org/usr_22.txt.html#22.4">:h 22.4</a> and <a href="https://vimhelp.org/windows.txt.html#buffer-hidden">:h buffer-hidden</a> for user and reference manuals on working with buffer list.</p> |
| 53 | +<p><strong>Video demo</strong>:</p> |
| 54 | +<p align="center"><iframe width="560" height="315" loading="lazy" src="https://www.youtube.com/embed/dJO16IwfSko" title="YouTube video player" frameborder="0" allow="accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></p> |
| 55 | +<br> |
| 56 | +<p><img src="/images/info.svg" alt="info" /> See also my <a href="https://github.com/learnbyexample/vim_reference">Vim Reference Guide</a> and <a href="https://learnbyexample.github.io/curated_resources/vim.html">curated list of resources for Vim</a>.</p> |
| 57 | +</content> |
| 58 | + </entry> |
10 | 59 | <entry xml:lang="en">
|
11 | 60 | <title>CLI tip 20: expand and unexpand</title>
|
12 | 61 | <published>2022-12-14T00:00:00+00:00</published>
|
|
0 commit comments