Skip to content

Commit e4c1cde

Browse files
added 21st Vim tip
1 parent 23cbeb4 commit e4c1cde

File tree

9 files changed

+78
-7
lines changed

9 files changed

+78
-7
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ I'm addicted to reading fantasy/sci-fi books, so I have a [blog](https://learnby
6565

6666
## Tips
6767

68+
* [Vim tip 21: working with tabs](https://learnbyexample.github.io/tips/vim-tip-21/)
6869
* [CLI tip 22: grep options to suppress stdout and stderr](https://learnbyexample.github.io/tips/cli-tip-22/)
6970
* [Python tip 22: possessive quantifiers](https://learnbyexample.github.io/tips/python-tip-22/)
7071
* [Vim tip 20: character based motions within the current line](https://learnbyexample.github.io/tips/vim-tip-20/)

atom.xml

Lines changed: 66 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,73 @@
55
<link href="https://learnbyexample.github.io/atom.xml" rel="self" type="application/atom+xml"/>
66
<link href="https://learnbyexample.github.io"/>
77
<generator uri="https://www.getzola.org/">Zola</generator>
8-
<updated>2023-01-31T00:00:00+00:00</updated>
8+
<updated>2023-02-01T00:00:00+00:00</updated>
99
<id>https://learnbyexample.github.io/atom.xml</id>
10+
<entry xml:lang="en">
11+
<title>Vim tip 21: working with tabs</title>
12+
<published>2023-02-01T00:00:00+00:00</published>
13+
<updated>2023-02-01T00:00:00+00:00</updated>
14+
<link rel="alternate" href="https://learnbyexample.github.io/tips/vim-tip-21/" type="text/html"/>
15+
<id>https://learnbyexample.github.io/tips/vim-tip-21/</id>
16+
<content type="html">&lt;p&gt;Multiple files can be opened in Vim within the same tab page and&#x2F;or in different tabs. From &lt;a href=&quot;https:&#x2F;&#x2F;vimhelp.org&#x2F;windows.txt.html#windows-intro&quot;&gt;:h windows-intro&lt;&#x2F;a&gt;:&lt;&#x2F;p&gt;
17+
&lt;blockquote&gt;
18+
&lt;ul&gt;
19+
&lt;li&gt;A buffer is the in-memory text of a file.&lt;&#x2F;li&gt;
20+
&lt;li&gt;A window is a viewport on a buffer.&lt;&#x2F;li&gt;
21+
&lt;li&gt;A tab page is a collection of windows.&lt;&#x2F;li&gt;
22+
&lt;&#x2F;ul&gt;
23+
&lt;&#x2F;blockquote&gt;
24+
&lt;ul&gt;
25+
&lt;li&gt;&lt;kbd&gt;:tabe filename&lt;&#x2F;kbd&gt; open the given file in a new tab (&lt;code&gt;:tabe&lt;&#x2F;code&gt; is short for &lt;code&gt;:tabedit&lt;&#x2F;code&gt;)
26+
&lt;ul&gt;
27+
&lt;li&gt;if &lt;code&gt;filename&lt;&#x2F;code&gt; isn&#x27;t specified, you&#x27;ll get an unnamed empty window&lt;&#x2F;li&gt;
28+
&lt;li&gt;by default, the new tab is opened to the right of the current tab&lt;&#x2F;li&gt;
29+
&lt;li&gt;&lt;kbd&gt;:0tabe&lt;&#x2F;kbd&gt; open as the first tab&lt;&#x2F;li&gt;
30+
&lt;li&gt;&lt;kbd&gt;:$tabe&lt;&#x2F;kbd&gt; open as the last tab&lt;&#x2F;li&gt;
31+
&lt;li&gt;see &lt;a href=&quot;https:&#x2F;&#x2F;vimhelp.org&#x2F;tabpage.txt.html#%3Atabnew&quot;&gt;:h :tabe&lt;&#x2F;a&gt; for more details and features&lt;&#x2F;li&gt;
32+
&lt;&#x2F;ul&gt;
33+
&lt;&#x2F;li&gt;
34+
&lt;&#x2F;ul&gt;
35+
&lt;p&gt;Switching between tabs:&lt;&#x2F;p&gt;
36+
&lt;ul&gt;
37+
&lt;li&gt;&lt;kbd&gt;:tabn&lt;&#x2F;kbd&gt; switch to the next tab (&lt;code&gt;:tabn&lt;&#x2F;code&gt; is short for &lt;code&gt;:tabnext&lt;&#x2F;code&gt;)
38+
&lt;ul&gt;
39+
&lt;li&gt;if tabs to the right are exhausted, switch to the first tab&lt;&#x2F;li&gt;
40+
&lt;li&gt;&lt;kbd&gt;gt&lt;&#x2F;kbd&gt; and &lt;kbd&gt;Ctrl&lt;&#x2F;kbd&gt;+&lt;kbd&gt;Page Down&lt;&#x2F;kbd&gt; can also be used&lt;&#x2F;li&gt;
41+
&lt;li&gt;&lt;kbd&gt;2gt&lt;&#x2F;kbd&gt; switch to the second tab (the number specified is absolute, not relative)&lt;&#x2F;li&gt;
42+
&lt;&#x2F;ul&gt;
43+
&lt;&#x2F;li&gt;
44+
&lt;li&gt;&lt;kbd&gt;:tabp&lt;&#x2F;kbd&gt; switch to the previous tab (&lt;code&gt;:tabp&lt;&#x2F;code&gt; is short for &lt;code&gt;:tabprevious&lt;&#x2F;code&gt;)
45+
&lt;ul&gt;
46+
&lt;li&gt;if tabs to the left are exhausted, switch to the last tab&lt;&#x2F;li&gt;
47+
&lt;li&gt;&lt;kbd&gt;gT&lt;&#x2F;kbd&gt; and &lt;kbd&gt;Ctrl&lt;&#x2F;kbd&gt;+&lt;kbd&gt;Page Up&lt;&#x2F;kbd&gt; can also be used&lt;&#x2F;li&gt;
48+
&lt;&#x2F;ul&gt;
49+
&lt;&#x2F;li&gt;
50+
&lt;li&gt;&lt;kbd&gt;:tabr&lt;&#x2F;kbd&gt; switch to the first tab (&lt;code&gt;:tabr&lt;&#x2F;code&gt; is short for &lt;code&gt;:tabrewind&lt;&#x2F;code&gt;)
51+
&lt;ul&gt;
52+
&lt;li&gt;&lt;kbd&gt;:tabfirst&lt;&#x2F;kbd&gt; can also be used&lt;&#x2F;li&gt;
53+
&lt;&#x2F;ul&gt;
54+
&lt;&#x2F;li&gt;
55+
&lt;li&gt;&lt;kbd&gt;:tabl&lt;&#x2F;kbd&gt; switch to the last tab (&lt;code&gt;:tabl&lt;&#x2F;code&gt; is short for &lt;code&gt;:tablast&lt;&#x2F;code&gt;)&lt;&#x2F;li&gt;
56+
&lt;&#x2F;ul&gt;
57+
&lt;p&gt;Moving tabs:&lt;&#x2F;p&gt;
58+
&lt;ul&gt;
59+
&lt;li&gt;&lt;kbd&gt;:tabm N&lt;&#x2F;kbd&gt; move the current tab to after &lt;code&gt;N&lt;&#x2F;code&gt; tabs from the start (&lt;code&gt;:tabm&lt;&#x2F;code&gt; is short for &lt;code&gt;:tabmove&lt;&#x2F;code&gt;)
60+
&lt;ul&gt;
61+
&lt;li&gt;&lt;kbd&gt;:tabm 0&lt;&#x2F;kbd&gt; move the current tab to the beginning&lt;&#x2F;li&gt;
62+
&lt;li&gt;&lt;kbd&gt;:tabm&lt;&#x2F;kbd&gt; move the current tab to the end&lt;&#x2F;li&gt;
63+
&lt;&#x2F;ul&gt;
64+
&lt;&#x2F;li&gt;
65+
&lt;li&gt;&lt;kbd&gt;:tabm +N&lt;&#x2F;kbd&gt; move the current tab &lt;code&gt;N&lt;&#x2F;code&gt; positions to the right&lt;&#x2F;li&gt;
66+
&lt;li&gt;&lt;kbd&gt;:tabm -N&lt;&#x2F;kbd&gt; move the current tab &lt;code&gt;N&lt;&#x2F;code&gt; positions to the left&lt;&#x2F;li&gt;
67+
&lt;&#x2F;ul&gt;
68+
&lt;p&gt;&lt;img src=&quot;&#x2F;images&#x2F;info.svg&quot; alt=&quot;info&quot; &#x2F;&gt; Buffer list includes all the files opened in all the tabs. You can also use the mouse to switch&#x2F;move tabs in GVim.&lt;&#x2F;p&gt;
69+
&lt;p&gt;&lt;strong&gt;Video demo&lt;&#x2F;strong&gt;:&lt;&#x2F;p&gt;
70+
&lt;p align=&quot;center&quot;&gt;&lt;iframe width=&quot;560&quot; height=&quot;315&quot; loading=&quot;lazy&quot; src=&quot;https:&#x2F;&#x2F;www.youtube.com&#x2F;embed&#x2F;pQpWrrrYVTI&quot; title=&quot;YouTube video player&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture&quot; allowfullscreen&gt;&lt;&#x2F;iframe&gt;&lt;&#x2F;p&gt;
71+
&lt;br&gt;
72+
&lt;p&gt;&lt;img src=&quot;&#x2F;images&#x2F;info.svg&quot; alt=&quot;info&quot; &#x2F;&gt; See also my &lt;a href=&quot;https:&#x2F;&#x2F;github.com&#x2F;learnbyexample&#x2F;vim_reference&quot;&gt;Vim Reference Guide&lt;&#x2F;a&gt; and &lt;a href=&quot;https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;curated_resources&#x2F;vim.html&quot;&gt;curated list of resources for Vim&lt;&#x2F;a&gt;.&lt;&#x2F;p&gt;
73+
</content>
74+
</entry>
1075
<entry xml:lang="en">
1176
<title>Understanding Python re(gex)? book announcement</title>
1277
<published>2023-01-30T00:00:00+00:00</published>

sitemap.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@
410410
</url>
411411
<url>
412412
<loc>https://learnbyexample.github.io/tips/</loc>
413-
<lastmod>2023-01-25</lastmod>
413+
<lastmod>2023-02-01</lastmod>
414414
</url>
415415
<url>
416416
<loc>https://learnbyexample.github.io/tips/cli-tip-1/</loc>
@@ -640,6 +640,10 @@
640640
<loc>https://learnbyexample.github.io/tips/vim-tip-20/</loc>
641641
<lastmod>2023-01-10</lastmod>
642642
</url>
643+
<url>
644+
<loc>https://learnbyexample.github.io/tips/vim-tip-21/</loc>
645+
<lastmod>2023-02-01</lastmod>
646+
</url>
643647
<url>
644648
<loc>https://learnbyexample.github.io/tips/vim-tip-3/</loc>
645649
<lastmod>2022-01-18</lastmod>

tags/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

tags/tip/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

tags/vim/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

tips/index.html

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

tips/vim-tip-20/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<!doctype html><html lang=en><head><meta content="IE=edge" http-equiv=X-UA-Compatible><meta content="text/html; charset=utf-8" http-equiv=content-type><meta content="width=device-width,initial-scale=1.0,maximum-scale=1" name=viewport><title>Vim tip 20: character based motions within the current line</title><link href=https://learnbyexample.github.io/atom.xml rel=alternate title=RSS type=application/atom+xml><script src=https://cdnjs.cloudflare.com/ajax/libs/slideout/1.0.1/slideout.min.js></script><link href=https://learnbyexample.github.io/site.css rel=stylesheet><meta content=learnbyexample property=og:title><meta content=website property=og:type><meta content="Learn Python, Regex, Linux, Scripting, Vim, Ebooks, Self-Publishing and Interesting Tech Nuggets." property=og:description><meta content=https://learnbyexample.github.io property=og:url><meta content=https://learnbyexample.github.io/images/learnbyexample.png property=og:image><meta content=1280 property=og:image:width><meta content=640 property=og:image:height><meta content=summary_large_image property=twitter:card><meta content=@learn_byexample property=twitter:site><link href=https://learnbyexample.github.io/favicon.svg rel=icon><link rel="shortcut icon" href=https://learnbyexample.github.io/favicon.png><body><div class=container><div class=mobile-navbar id=mobile-navbar><div class=mobile-header-logo><a class=logo href=/>learnbyexample</a></div><div class="mobile-navbar-icon icon-out"><span></span><span></span><span></span></div></div><nav class="mobile-menu slideout-menu slideout-menu-left" id=mobile-menu><ul class=mobile-menu-list><li class=mobile-menu-item><a href=https://learnbyexample.github.io/books> Books </a><li class=mobile-menu-item><a href=https://learnbyexample.github.io/mini> Mini </a><li class=mobile-menu-item><a href=https://learnbyexample.github.io/tips> Tips </a><li class=mobile-menu-item><a href=https://learnbyexample.github.io/tags> Tags </a><li class=mobile-menu-item><a href=https://learnbyexample.github.io/about> About </a></ul></nav><header id=header><div class=logo><a href=https://learnbyexample.github.io>learnbyexample</a></div><nav class=menu><ul><li><a href=https://learnbyexample.github.io/books> Books </a><li><a href=https://learnbyexample.github.io/mini> Mini </a><li><a href=https://learnbyexample.github.io/tips> Tips </a><li><a href=https://learnbyexample.github.io/tags> Tags </a><li><a href=https://learnbyexample.github.io/about> About </a></ul></nav></header><main><div class=content id=mobile-panel><article class=post><header class=post__header><h1 class=post__title><a href=https://learnbyexample.github.io/tips/vim-tip-20/>Vim tip 20: character based motions within the current line</a></h1><div class=post__meta><span class=post__time>2023-01-10</span></div></header><div class=post-content><p>These commands allow you to move based on a single character search, <strong>within the current line only</strong>.<ul><li><kbd>f(</kbd> move forward to the next occurrence of character <code>(</code><li><kbd>fb</kbd> move forward to the next occurrence of character <code>b</code><li><kbd>3f"</kbd> move forward to the third occurrence of character <code>"</code><li><kbd>t;</kbd> move forward to the character just before <code>;</code><li><kbd>3tx</kbd> move forward to the character just before the third occurrence of character <code>x</code><li><kbd>Fa</kbd> move backward to the character <code>a</code><li><kbd>Ta</kbd> move backward to the character just after <code>a</code><li><kbd>;</kbd> repeat previous <code>f</code> or <code>F</code> or <code>t</code> or <code>T</code> motion in the same direction<li><kbd>,</kbd> repeat previous <code>f</code> or <code>F</code> or <code>t</code> or <code>T</code> motion in the opposite direction <ul><li>for example, <kbd>tc</kbd> becomes <kbd>Tc</kbd> and vice versa</ul></ul><p><img alt=info src=/images/info.svg> Note that the previously used count prefix wouldn't be repeated with <kbd>;</kbd> or <kbd>,</kbd> commands, but you can use a new count prefix. If you pressed a wrong motion command, use the <kbd>Esc</kbd> key to abandon the search instead of continuing with the wrongly chosen command.<p><strong>Video demo</strong>:<p align=center><iframe allow="accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture" title="YouTube video player" allowfullscreen frameborder=0 height=315 loading=lazy src=https://www.youtube.com/embed/WFRJmeaQr60 width=560></iframe></p><br><p><img alt=info src=/images/info.svg> 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>.</div><div class=post-footer><div class=post-tags><a href=https://learnbyexample.github.io/tags/vim/>#vim</a><a href=https://learnbyexample.github.io/tags/tip/>#tip</a></div><hr color=#e6e6e6><div class=post-nav><p><a class=next href=https://learnbyexample.github.io/tips/vim-tip-19/>Vim tip 19: working with buffers →</a><br></div><hr color=#e6e6e6><p>📰 Use <a href=https://learnbyexample.github.io/atom.xml>this link</a> for the Atom feed. <br> ✅ Follow me on <a href=https://twitter.com/learn_byexample>Twitter</a>, <a href=https://github.com/learnbyexample>GitHub</a> and <a href=https://www.youtube.com/c/learnbyexample42>Youtube</a> for interesting tech nuggets. <br> 📧 Subscribe to <a href=https://learnbyexample.gumroad.com/l/learnbyexample-weekly>learnbyexample weekly</a> for programming resources, tips, tools, free ebooks and more (free newsletter, delivered every Friday).<hr color=#e6e6e6></div></article></div></main></div><script src=https://learnbyexample.github.io/even.js></script>
1+
<!doctype html><html lang=en><head><meta content="IE=edge" http-equiv=X-UA-Compatible><meta content="text/html; charset=utf-8" http-equiv=content-type><meta content="width=device-width,initial-scale=1.0,maximum-scale=1" name=viewport><title>Vim tip 20: character based motions within the current line</title><link href=https://learnbyexample.github.io/atom.xml rel=alternate title=RSS type=application/atom+xml><script src=https://cdnjs.cloudflare.com/ajax/libs/slideout/1.0.1/slideout.min.js></script><link href=https://learnbyexample.github.io/site.css rel=stylesheet><meta content=learnbyexample property=og:title><meta content=website property=og:type><meta content="Learn Python, Regex, Linux, Scripting, Vim, Ebooks, Self-Publishing and Interesting Tech Nuggets." property=og:description><meta content=https://learnbyexample.github.io property=og:url><meta content=https://learnbyexample.github.io/images/learnbyexample.png property=og:image><meta content=1280 property=og:image:width><meta content=640 property=og:image:height><meta content=summary_large_image property=twitter:card><meta content=@learn_byexample property=twitter:site><link href=https://learnbyexample.github.io/favicon.svg rel=icon><link rel="shortcut icon" href=https://learnbyexample.github.io/favicon.png><body><div class=container><div class=mobile-navbar id=mobile-navbar><div class=mobile-header-logo><a class=logo href=/>learnbyexample</a></div><div class="mobile-navbar-icon icon-out"><span></span><span></span><span></span></div></div><nav class="mobile-menu slideout-menu slideout-menu-left" id=mobile-menu><ul class=mobile-menu-list><li class=mobile-menu-item><a href=https://learnbyexample.github.io/books> Books </a><li class=mobile-menu-item><a href=https://learnbyexample.github.io/mini> Mini </a><li class=mobile-menu-item><a href=https://learnbyexample.github.io/tips> Tips </a><li class=mobile-menu-item><a href=https://learnbyexample.github.io/tags> Tags </a><li class=mobile-menu-item><a href=https://learnbyexample.github.io/about> About </a></ul></nav><header id=header><div class=logo><a href=https://learnbyexample.github.io>learnbyexample</a></div><nav class=menu><ul><li><a href=https://learnbyexample.github.io/books> Books </a><li><a href=https://learnbyexample.github.io/mini> Mini </a><li><a href=https://learnbyexample.github.io/tips> Tips </a><li><a href=https://learnbyexample.github.io/tags> Tags </a><li><a href=https://learnbyexample.github.io/about> About </a></ul></nav></header><main><div class=content id=mobile-panel><article class=post><header class=post__header><h1 class=post__title><a href=https://learnbyexample.github.io/tips/vim-tip-20/>Vim tip 20: character based motions within the current line</a></h1><div class=post__meta><span class=post__time>2023-01-10</span></div></header><div class=post-content><p>These commands allow you to move based on a single character search, <strong>within the current line only</strong>.<ul><li><kbd>f(</kbd> move forward to the next occurrence of character <code>(</code><li><kbd>fb</kbd> move forward to the next occurrence of character <code>b</code><li><kbd>3f"</kbd> move forward to the third occurrence of character <code>"</code><li><kbd>t;</kbd> move forward to the character just before <code>;</code><li><kbd>3tx</kbd> move forward to the character just before the third occurrence of character <code>x</code><li><kbd>Fa</kbd> move backward to the character <code>a</code><li><kbd>Ta</kbd> move backward to the character just after <code>a</code><li><kbd>;</kbd> repeat previous <code>f</code> or <code>F</code> or <code>t</code> or <code>T</code> motion in the same direction<li><kbd>,</kbd> repeat previous <code>f</code> or <code>F</code> or <code>t</code> or <code>T</code> motion in the opposite direction <ul><li>for example, <kbd>tc</kbd> becomes <kbd>Tc</kbd> and vice versa</ul></ul><p><img alt=info src=/images/info.svg> Note that the previously used count prefix wouldn't be repeated with <kbd>;</kbd> or <kbd>,</kbd> commands, but you can use a new count prefix. If you pressed a wrong motion command, use the <kbd>Esc</kbd> key to abandon the search instead of continuing with the wrongly chosen command.<p><strong>Video demo</strong>:<p align=center><iframe allow="accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture" title="YouTube video player" allowfullscreen frameborder=0 height=315 loading=lazy src=https://www.youtube.com/embed/WFRJmeaQr60 width=560></iframe></p><br><p><img alt=info src=/images/info.svg> 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>.</div><div class=post-footer><div class=post-tags><a href=https://learnbyexample.github.io/tags/vim/>#vim</a><a href=https://learnbyexample.github.io/tags/tip/>#tip</a></div><hr color=#e6e6e6><div class=post-nav><p><a class=previous href=https://learnbyexample.github.io/tips/vim-tip-21/>← Vim tip 21: working with tabs</a><br><p><a class=next href=https://learnbyexample.github.io/tips/vim-tip-19/>Vim tip 19: working with buffers →</a><br></div><hr color=#e6e6e6><p>📰 Use <a href=https://learnbyexample.github.io/atom.xml>this link</a> for the Atom feed. <br> ✅ Follow me on <a href=https://twitter.com/learn_byexample>Twitter</a>, <a href=https://github.com/learnbyexample>GitHub</a> and <a href=https://www.youtube.com/c/learnbyexample42>Youtube</a> for interesting tech nuggets. <br> 📧 Subscribe to <a href=https://learnbyexample.gumroad.com/l/learnbyexample-weekly>learnbyexample weekly</a> for programming resources, tips, tools, free ebooks and more (free newsletter, delivered every Friday).<hr color=#e6e6e6></div></article></div></main></div><script src=https://learnbyexample.github.io/even.js></script>

0 commit comments

Comments
 (0)