Skip to content

Commit 1754144

Browse files
added 28th vim tip
1 parent e8dee97 commit 1754144

File tree

9 files changed

+44
-7
lines changed

9 files changed

+44
-7
lines changed

Diff for: README.md

+1
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ I'm addicted to reading fantasy/sci-fi books, so I have a [blog](https://learnby
6868

6969
## Tips
7070

71+
* [Vim tip 28: miscellaneous motion and reposition commands](https://learnbyexample.github.io/tips/vim-tip-28/)
7172
* [CLI tip 29: define fields using FPAT in GNU awk](https://learnbyexample.github.io/tips/cli-tip-29/)
7273
* [Python tip 29: negative lookarounds](https://learnbyexample.github.io/tips/python-tip-29/)
7374
* [Vim tip 27: regexp anchors](https://learnbyexample.github.io/tips/vim-tip-27/)

Diff for: atom.xml

+32-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,39 @@
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-06-20T00:00:00+00:00</updated>
8+
<updated>2023-06-26T00:00:00+00:00</updated>
99
<id>https://learnbyexample.github.io/atom.xml</id>
10+
<entry xml:lang="en">
11+
<title>Vim tip 28: miscellaneous motion and reposition commands</title>
12+
<published>2023-06-26T00:00:00+00:00</published>
13+
<updated>2023-06-26T00:00:00+00:00</updated>
14+
<link rel="alternate" href="https://learnbyexample.github.io/tips/vim-tip-28/" type="text/html"/>
15+
<id>https://learnbyexample.github.io/tips/vim-tip-28/</id>
16+
<content type="html">&lt;p&gt;Moving within the visible window:&lt;&#x2F;p&gt;
17+
&lt;ul&gt;
18+
&lt;li&gt;&lt;kbd&gt;H&lt;&#x2F;kbd&gt; move to the first non-blank character of the top (home) line of the visible window&lt;&#x2F;li&gt;
19+
&lt;li&gt;&lt;kbd&gt;M&lt;&#x2F;kbd&gt; move to the first non-blank character of the middle line of the visible window&lt;&#x2F;li&gt;
20+
&lt;li&gt;&lt;kbd&gt;L&lt;&#x2F;kbd&gt; move to the first non-blank character of the bottom (low) line of the visible window&lt;&#x2F;li&gt;
21+
&lt;&#x2F;ul&gt;
22+
&lt;p&gt;Reposition the current line:&lt;&#x2F;p&gt;
23+
&lt;ul&gt;
24+
&lt;li&gt;&lt;kbd&gt;Ctrl&lt;&#x2F;kbd&gt;+&lt;kbd&gt;e&lt;&#x2F;kbd&gt; scroll up by a line&lt;&#x2F;li&gt;
25+
&lt;li&gt;&lt;kbd&gt;Ctrl&lt;&#x2F;kbd&gt;+&lt;kbd&gt;y&lt;&#x2F;kbd&gt; scroll down by a line&lt;&#x2F;li&gt;
26+
&lt;li&gt;&lt;kbd&gt;zz&lt;&#x2F;kbd&gt; reposition the current line to the middle of the visible window
27+
&lt;ul&gt;
28+
&lt;li&gt;useful to see context around lines that are nearer to the top&#x2F;bottom of the visible window&lt;&#x2F;li&gt;
29+
&lt;&#x2F;ul&gt;
30+
&lt;&#x2F;li&gt;
31+
&lt;li&gt;&lt;kbd&gt;zt&lt;&#x2F;kbd&gt; reposition the current line to the top of the visible window&lt;&#x2F;li&gt;
32+
&lt;li&gt;&lt;kbd&gt;zb&lt;&#x2F;kbd&gt; reposition the current line to the bottom of the visible window&lt;&#x2F;li&gt;
33+
&lt;&#x2F;ul&gt;
34+
&lt;p&gt;&lt;img src=&quot;&#x2F;images&#x2F;info.svg&quot; alt=&quot;info&quot; &#x2F;&gt; See &lt;a href=&quot;https:&#x2F;&#x2F;vimhelp.org&#x2F;options.txt.html#%27scrolloff%27&quot;&gt;:h &#x27;scrolloff&#x27;&lt;&#x2F;a&gt; option if you want to always show context around the current line.&lt;&#x2F;p&gt;
35+
&lt;p&gt;&lt;strong&gt;Video demo&lt;&#x2F;strong&gt;:&lt;&#x2F;p&gt;
36+
&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;XRXO4Ns8rPE&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;
37+
&lt;br&gt;
38+
&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;
39+
</content>
40+
</entry>
1041
<entry xml:lang="en">
1142
<title>CLI tip 29: define fields using FPAT in GNU awk</title>
1243
<published>2023-06-20T00:00:00+00:00</published>

Diff for: sitemap.xml

+5-1
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@
428428
</url>
429429
<url>
430430
<loc>https://learnbyexample.github.io/tips/</loc>
431-
<lastmod>2023-06-20</lastmod>
431+
<lastmod>2023-06-26</lastmod>
432432
</url>
433433
<url>
434434
<loc>https://learnbyexample.github.io/tips/cli-tip-1/</loc>
@@ -742,6 +742,10 @@
742742
<loc>https://learnbyexample.github.io/tips/vim-tip-27/</loc>
743743
<lastmod>2023-06-05</lastmod>
744744
</url>
745+
<url>
746+
<loc>https://learnbyexample.github.io/tips/vim-tip-28/</loc>
747+
<lastmod>2023-06-26</lastmod>
748+
</url>
745749
<url>
746750
<loc>https://learnbyexample.github.io/tips/vim-tip-3/</loc>
747751
<lastmod>2022-01-18</lastmod>

Diff for: tags/index.html

+1-1
Large diffs are not rendered by default.

Diff for: tags/tip/index.html

+1-1
Large diffs are not rendered by default.

Diff for: tags/vim/index.html

+1-1
Large diffs are not rendered by default.

Diff for: tips/index.html

+1-1
Large diffs are not rendered by default.

Diff for: tips/vim-tip-27/index.html

+1-1
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 27: regexp anchors</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="Vim tip 27: regexp anchors" property=og:title><meta content=website property=og:type><meta content=https://learnbyexample.github.io/vim-tip-27/ property=og:url><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-27/>Vim tip 27: regexp anchors</a></h1><div class=post__meta><span class=post__time>2023-06-05</span></div></header><div class=post-content><p>By default, regexp matches anywhere in the text. You can use line and word anchors to specify additional restrictions regarding the position of matches. These restrictions are made possible by assigning special meaning to certain characters (<strong>metacharacters</strong>) and escape sequences.<ul><li><code>^</code> restricts the match to the start-of-line <ul><li><code>^This</code> matches <code>This is a sample</code> but not <code>Do This</code></ul><li><code>$</code> restricts the match to the end-of-line <ul><li><code>)$</code> matches <code>apple (5)</code> but not <code>def greeting():</code></ul><li><code>^$</code> match empty line<li><code>\&LTpattern</code> restricts the match to the start of a word <ul><li>word characters include alphabets, digits and underscore<li><code>\&LThis</code> matches <code>his</code> or <code>to-his</code> or <code>history</code> but not <code>this</code> or <code>_hist</code></ul><li><code>pattern\></code> restricts the match to the end of a word <ul><li><code>his\></code> matches <code>his</code> or <code>to-his</code> or <code>this</code> but not <code>history</code> or <code>_hist</code></ul><li><code>\&LTpattern\></code> restricts the match between start of a word and end of a word <ul><li><code>\&LThis\></code> matches <code>his</code> or <code>to-his</code> but not <code>this</code> or <code>history</code> or <code>_hist</code></ul></ul><p><img alt=info src=/images/info.svg> End-of-line can be <code>\r</code> (carriage return), <code>\n</code> (newline) or <code>\r\n</code> depending on your system and <code>fileformat</code> setting.<p><img alt=info src=/images/info.svg> See <a href=https://vimhelp.org/pattern.txt.html#pattern-atoms>:h pattern-atoms</a> for more details.<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/AJNWtpKA2zM 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-26/>Vim tip 26: executing shell commands →</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 27: regexp anchors</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="Vim tip 27: regexp anchors" property=og:title><meta content=website property=og:type><meta content=https://learnbyexample.github.io/vim-tip-27/ property=og:url><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-27/>Vim tip 27: regexp anchors</a></h1><div class=post__meta><span class=post__time>2023-06-05</span></div></header><div class=post-content><p>By default, regexp matches anywhere in the text. You can use line and word anchors to specify additional restrictions regarding the position of matches. These restrictions are made possible by assigning special meaning to certain characters (<strong>metacharacters</strong>) and escape sequences.<ul><li><code>^</code> restricts the match to the start-of-line <ul><li><code>^This</code> matches <code>This is a sample</code> but not <code>Do This</code></ul><li><code>$</code> restricts the match to the end-of-line <ul><li><code>)$</code> matches <code>apple (5)</code> but not <code>def greeting():</code></ul><li><code>^$</code> match empty line<li><code>\&LTpattern</code> restricts the match to the start of a word <ul><li>word characters include alphabets, digits and underscore<li><code>\&LThis</code> matches <code>his</code> or <code>to-his</code> or <code>history</code> but not <code>this</code> or <code>_hist</code></ul><li><code>pattern\></code> restricts the match to the end of a word <ul><li><code>his\></code> matches <code>his</code> or <code>to-his</code> or <code>this</code> but not <code>history</code> or <code>_hist</code></ul><li><code>\&LTpattern\></code> restricts the match between start of a word and end of a word <ul><li><code>\&LThis\></code> matches <code>his</code> or <code>to-his</code> but not <code>this</code> or <code>history</code> or <code>_hist</code></ul></ul><p><img alt=info src=/images/info.svg> End-of-line can be <code>\r</code> (carriage return), <code>\n</code> (newline) or <code>\r\n</code> depending on your system and <code>fileformat</code> setting.<p><img alt=info src=/images/info.svg> See <a href=https://vimhelp.org/pattern.txt.html#pattern-atoms>:h pattern-atoms</a> for more details.<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/AJNWtpKA2zM 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-28/>← Vim tip 28: miscellaneous motion and reposition commands</a><br><p><a class=next href=https://learnbyexample.github.io/tips/vim-tip-26/>Vim tip 26: executing shell commands →</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)