Skip to content

Commit b14ae67

Browse files
added 11th Vim tip, updated books page
1 parent e25418e commit b14ae67

File tree

9 files changed

+269
-6
lines changed

9 files changed

+269
-6
lines changed

Diff for: README.md

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

5757
## Tips
5858

59+
* [Vim tip 11: replace characters in Normal mode](https://learnbyexample.github.io/tips/vim-tip-11/)
5960
* [CLI tip 12: squeeze empty lines](https://learnbyexample.github.io/tips/cli-tip-12/)
6061
* [Python tip 12: negate a regex grouping](https://learnbyexample.github.io/tips/python-tip-12/)
6162
* [Vim tip 10: Undo and Redo](https://learnbyexample.github.io/tips/vim-tip-10/)

Diff for: atom.xml

+34-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,41 @@
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>2022-06-29T00:00:00+00:00</updated>
8+
<updated>2022-07-06T00:00:00+00:00</updated>
99
<id>https://learnbyexample.github.io/atom.xml</id>
10+
<entry xml:lang="en">
11+
<title>Vim tip 11: replace characters in Normal mode</title>
12+
<published>2022-07-06T00:00:00+00:00</published>
13+
<updated>2022-07-06T00:00:00+00:00</updated>
14+
<link href="https://learnbyexample.github.io/tips/vim-tip-11/" type="text/html"/>
15+
<id>https://learnbyexample.github.io/tips/vim-tip-11/</id>
16+
<content type="html">&lt;p&gt;Often, you just need to change one character. For example, changing &lt;code&gt;i&lt;&#x2F;code&gt; to &lt;code&gt;j&lt;&#x2F;code&gt;, &lt;code&gt;2&lt;&#x2F;code&gt; to &lt;code&gt;4&lt;&#x2F;code&gt;, &lt;code&gt;&#x27;&lt;&#x2F;code&gt; to &lt;code&gt;&amp;quot;&lt;&#x2F;code&gt; and so on.&lt;&#x2F;p&gt;
17+
&lt;ul&gt;
18+
&lt;li&gt;&lt;kbd&gt;rj&lt;&#x2F;kbd&gt; replace the character under the cursor with &lt;code&gt;j&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
19+
&lt;li&gt;&lt;kbd&gt;ry&lt;&#x2F;kbd&gt; replace the character under the cursor with &lt;code&gt;y&lt;&#x2F;code&gt;&lt;&#x2F;li&gt;
20+
&lt;li&gt;&lt;kbd&gt;3ra&lt;&#x2F;kbd&gt; replace the character under cursor as well as the two characters to the right with &lt;code&gt;aaa&lt;&#x2F;code&gt;
21+
&lt;ul&gt;
22+
&lt;li&gt;no changes will be made if there aren&#x27;t sufficient characters to match&lt;&#x2F;li&gt;
23+
&lt;&#x2F;ul&gt;
24+
&lt;&#x2F;li&gt;
25+
&lt;&#x2F;ul&gt;
26+
&lt;p&gt;To replace multiple characters with different characters, use &lt;code&gt;R&lt;&#x2F;code&gt;.&lt;&#x2F;p&gt;
27+
&lt;ul&gt;
28+
&lt;li&gt;&lt;kbd&gt;Rlion&lt;&#x2F;kbd&gt; followed by &lt;kbd&gt;Esc&lt;&#x2F;kbd&gt; replace the character under cursor and three characters to the right with &lt;code&gt;lion&lt;&#x2F;code&gt;
29+
&lt;ul&gt;
30+
&lt;li&gt;&lt;kbd&gt;Esc&lt;&#x2F;kbd&gt; key marks the completion of &lt;code&gt;R&lt;&#x2F;code&gt; command&lt;&#x2F;li&gt;
31+
&lt;li&gt;&lt;kbd&gt;Backspace&lt;&#x2F;kbd&gt; key will act as an undo command to give back the character that was replaced&lt;&#x2F;li&gt;
32+
&lt;li&gt;if you are replacing at the end of a line, the line will be automatically extended if needed&lt;&#x2F;li&gt;
33+
&lt;&#x2F;ul&gt;
34+
&lt;&#x2F;li&gt;
35+
&lt;&#x2F;ul&gt;
36+
&lt;p&gt;The advantage of &lt;code&gt;r&lt;&#x2F;code&gt; and &lt;code&gt;R&lt;&#x2F;code&gt; commands is that you remain in the Normal mode, without needing to switch to Insert mode and back.&lt;&#x2F;p&gt;
37+
&lt;p&gt;&lt;strong&gt;Video demo&lt;&#x2F;strong&gt;:&lt;&#x2F;p&gt;
38+
&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;cNRNiwIcqNc&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;
39+
&lt;br&gt;
40+
&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;
41+
</content>
42+
</entry>
1043
<entry xml:lang="en">
1144
<title>CLI tip 12: squeeze empty lines</title>
1245
<published>2022-06-29T00:00:00+00:00</published>

Diff for: books/index.html

+6-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,8 @@ <h2 id="bundles-books"><p style="color: #ff6600">Bundles 📚</h2>
134134
<li><strong>Awesome regex</strong>: <a href="https://leanpub.com/b/regex">leanpub</a> or <a href="https://learnbyexample.gumroad.com/l/regex">gumroad</a>
135135
<ul>
136136
<li>Python, Ruby, JavaScript Regular expressions</li>
137-
<li>GNU grep, ripgrep, GNU sed, GNU awk cli tools</li>
137+
<li>GNU grep, ripgrep, GNU sed, GNU awk cli tools (BRE/ERE, PCRE, Rust regex crate, PCRE2)</li>
138+
<li>Vim regexp</li>
138139
</ul>
139140
</li>
140141
<li><strong>Magical one-liners</strong>: <a href="https://leanpub.com/b/oneliners">leanpub</a> or <a href="https://learnbyexample.gumroad.com/l/oneliners">gumroad</a>
@@ -201,6 +202,10 @@ <h1 id="testimonials-heart-eyes"><p style="color: #c05b4d">Testimonials 😍</h1
201202
<p>Hi, great work releasing this! Trying to explain vim concisely is always an interesting challenge and I had a great time reading your attempt in this book. I always find it really interesting on how people try to group certain vim functions in a way that makes sense to people that don't use vim. I think you cover that idea pretty well in your 'Vim philosophy and features' section whilst not making it overly abstract and keeping it relatable.</p>
202203
<p><a href="https://news.ycombinator.com/item?id=30684232">feedback on Hacker News</a> by doix for &quot;Vim Reference Guide&quot;</p>
203204
</blockquote>
205+
<blockquote>
206+
<p>I consider myself pretty experienced at shell-fu and capable of doing most things I set out to achieve in either bash scripts or fearless one-liners. However, my awk is rudimentary at best, I think mostly because it's such an unforgiving environment to experiment in. These books you've written are great for a bit of first principles insight and then quickly building up to functional usage. I will have no hesitation in referring colleagues to them!</p>
207+
<p><a href="https://news.ycombinator.com/item?id=31930840">feedback on Hacker News</a></p>
208+
</blockquote>
204209
<br>
205210
<h2 id="100-page-python-intro"><p style="color: #ff9933">100 Page Python Intro</h2>
206211
<p>Short, introductory guide for the Python programming language, suited for those already familiar with programming basics.</p>

Diff for: sitemap.xml

+6-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
</url>
2121
<url>
2222
<loc>https://learnbyexample.github.io/books/</loc>
23-
<lastmod>2022-06-08</lastmod>
23+
<lastmod>2022-07-06</lastmod>
2424
</url>
2525
<url>
2626
<loc>https://learnbyexample.github.io/cli-text-processing-coreutils-announcement/</loc>
@@ -368,7 +368,7 @@
368368
</url>
369369
<url>
370370
<loc>https://learnbyexample.github.io/tips/</loc>
371-
<lastmod>2022-04-12</lastmod>
371+
<lastmod>2022-07-06</lastmod>
372372
</url>
373373
<url>
374374
<loc>https://learnbyexample.github.io/tips/cli-tip-1/</loc>
@@ -474,6 +474,10 @@
474474
<loc>https://learnbyexample.github.io/tips/vim-tip-10/</loc>
475475
<lastmod>2022-06-15</lastmod>
476476
</url>
477+
<url>
478+
<loc>https://learnbyexample.github.io/tips/vim-tip-11/</loc>
479+
<lastmod>2022-07-06</lastmod>
480+
</url>
477481
<url>
478482
<loc>https://learnbyexample.github.io/tips/vim-tip-2/</loc>
479483
<lastmod>2021-12-29</lastmod>

Diff for: tags/index.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@
404404

405405
<a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;tags&#x2F;tip&#x2F;">
406406
tip
407-
<span class="count">34</span>
407+
<span class="count">35</span>
408408
</a>
409409

410410
<a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;tags&#x2F;tutorial&#x2F;">
@@ -414,7 +414,7 @@
414414

415415
<a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;tags&#x2F;vim&#x2F;">
416416
vim
417-
<span class="count">15</span>
417+
<span class="count">16</span>
418418
</a>
419419

420420
<a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;tags&#x2F;wxpython&#x2F;">

Diff for: tags/tip/index.html

+7
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,13 @@
124124
<div class="taxonomy">
125125
<h2>tip</h2>
126126

127+
<div class="taxonomy__item">
128+
<span class="taxonomy__item__time">2022-07-06</span>
129+
<span class="taxonomy__item__title">
130+
<a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;tips&#x2F;vim-tip-11&#x2F;">Vim tip 11: replace characters in Normal mode</a>
131+
</span>
132+
</div>
133+
127134
<div class="taxonomy__item">
128135
<span class="taxonomy__item__time">2022-06-29</span>
129136
<span class="taxonomy__item__title">

Diff for: tags/vim/index.html

+7
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,13 @@
124124
<div class="taxonomy">
125125
<h2>vim</h2>
126126

127+
<div class="taxonomy__item">
128+
<span class="taxonomy__item__time">2022-07-06</span>
129+
<span class="taxonomy__item__title">
130+
<a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;tips&#x2F;vim-tip-11&#x2F;">Vim tip 11: replace characters in Normal mode</a>
131+
</span>
132+
</div>
133+
127134
<div class="taxonomy__item">
128135
<span class="taxonomy__item__time">2022-06-15</span>
129136
<span class="taxonomy__item__title">

Diff for: tips/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ <h2 id="command-line-tools-penguin"><p style="color: #ff6600"><a name="command-l
158158
<hr>
159159
<h2 id="vim-memo"><p style="color: #ff6600"><a name="vim"></a>Vim 📝</h2>
160160
<ul>
161+
<li><a href="https://learnbyexample.github.io/tips/vim-tip-11/">Vim tip 11: replace characters in Normal mode</a></li>
161162
<li><a href="https://learnbyexample.github.io/tips/vim-tip-10/">Vim tip 10: Undo and Redo</a></li>
162163
<li><a href="https://learnbyexample.github.io/tips/vim-tip-9/">Vim tip 9: named registers</a></li>
163164
<li><a href="https://learnbyexample.github.io/tips/vim-tip-7/">Vim tip 7: changing case in Normal mode</a></li>

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

+205
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
5+
<meta http-equiv="content-type" content="text/html; charset=utf-8">
6+
7+
<!-- Enable responsiveness on mobile devices-->
8+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1">
9+
10+
<title>Vim tip 11: replace characters in Normal mode</title>
11+
12+
13+
<link rel="alternate" type="application/atom+xml" title="RSS" href="https://learnbyexample.github.io/atom.xml">
14+
15+
16+
17+
<script src="https://cdnjs.cloudflare.com/ajax/libs/slideout/1.0.1/slideout.min.js"></script>
18+
19+
20+
21+
22+
<link rel="stylesheet" href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;site.css">
23+
24+
25+
26+
27+
28+
<link rel="icon" href="https://learnbyexample.github.io/favicon.svg">
29+
<link rel="shortcut icon" href="https://learnbyexample.github.io/favicon.png">
30+
</head>
31+
32+
<body>
33+
<div class="container">
34+
35+
<div id="mobile-navbar" class="mobile-navbar">
36+
<div class="mobile-header-logo">
37+
<a href="/" class="logo">learnbyexample</a>
38+
</div>
39+
<div class="mobile-navbar-icon icon-out">
40+
<span></span>
41+
<span></span>
42+
<span></span>
43+
</div>
44+
</div>
45+
46+
<nav id="mobile-menu" class="mobile-menu slideout-menu slideout-menu-left">
47+
<ul class="mobile-menu-list">
48+
49+
<li class="mobile-menu-item">
50+
<a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;books">
51+
Books
52+
</a>
53+
</li>
54+
55+
<li class="mobile-menu-item">
56+
<a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;mini">
57+
Mini
58+
</a>
59+
</li>
60+
61+
<li class="mobile-menu-item">
62+
<a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;tips">
63+
Tips
64+
</a>
65+
</li>
66+
67+
<li class="mobile-menu-item">
68+
<a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;tags">
69+
Tags
70+
</a>
71+
</li>
72+
73+
<li class="mobile-menu-item">
74+
<a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;about">
75+
About
76+
</a>
77+
</li>
78+
79+
</ul>
80+
</nav>
81+
82+
<header id="header">
83+
<div class="logo"><a href="https:&#x2F;&#x2F;learnbyexample.github.io">learnbyexample</a></div>
84+
<nav class="menu">
85+
<ul>
86+
87+
<li>
88+
<a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;books">
89+
Books
90+
</a>
91+
</li>
92+
93+
<li>
94+
<a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;mini">
95+
Mini
96+
</a>
97+
</li>
98+
99+
<li>
100+
<a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;tips">
101+
Tips
102+
</a>
103+
</li>
104+
105+
<li>
106+
<a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;tags">
107+
Tags
108+
</a>
109+
</li>
110+
111+
<li>
112+
<a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;about">
113+
About
114+
</a>
115+
</li>
116+
117+
</ul>
118+
</nav>
119+
</header>
120+
121+
<main>
122+
<div class="content" id="mobile-panel">
123+
124+
125+
126+
127+
<article class="post">
128+
129+
<header class="post__header">
130+
<h1 class="post__title">
131+
<a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;tips&#x2F;vim-tip-11&#x2F;">Vim tip 11: replace characters in Normal mode</a>
132+
</h1>
133+
<div class="post__meta">
134+
<span class="post__time">2022-07-06</span>
135+
136+
</div>
137+
</header>
138+
139+
<div class="post-content">
140+
<p>Often, you just need to change one character. For example, changing <code>i</code> to <code>j</code>, <code>2</code> to <code>4</code>, <code>'</code> to <code>&quot;</code> and so on.</p>
141+
<ul>
142+
<li><kbd>rj</kbd> replace the character under the cursor with <code>j</code></li>
143+
<li><kbd>ry</kbd> replace the character under the cursor with <code>y</code></li>
144+
<li><kbd>3ra</kbd> replace the character under cursor as well as the two characters to the right with <code>aaa</code>
145+
<ul>
146+
<li>no changes will be made if there aren't sufficient characters to match</li>
147+
</ul>
148+
</li>
149+
</ul>
150+
<p>To replace multiple characters with different characters, use <code>R</code>.</p>
151+
<ul>
152+
<li><kbd>Rlion</kbd> followed by <kbd>Esc</kbd> replace the character under cursor and three characters to the right with <code>lion</code>
153+
<ul>
154+
<li><kbd>Esc</kbd> key marks the completion of <code>R</code> command</li>
155+
<li><kbd>Backspace</kbd> key will act as an undo command to give back the character that was replaced</li>
156+
<li>if you are replacing at the end of a line, the line will be automatically extended if needed</li>
157+
</ul>
158+
</li>
159+
</ul>
160+
<p>The advantage of <code>r</code> and <code>R</code> commands is that you remain in the Normal mode, without needing to switch to Insert mode and back.</p>
161+
<p><strong>Video demo</strong>:</p>
162+
<p align="center"><iframe width="560" height="315" loading="lazy" src="https://www.youtube.com/embed/cNRNiwIcqNc" title="YouTube video player" frameborder="0" allow="accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></p>
163+
<br>
164+
<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>
165+
166+
</div>
167+
168+
169+
170+
171+
<div class="post-footer">
172+
173+
174+
<div class="post-tags">
175+
176+
<a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;tags&#x2F;vim&#x2F;">#vim</a>
177+
178+
<a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;tags&#x2F;tip&#x2F;">#tip</a>
179+
180+
</div>
181+
182+
183+
184+
185+
186+
</div>
187+
188+
189+
190+
</article>
191+
192+
193+
</div>
194+
</main>
195+
196+
197+
198+
</div>
199+
200+
201+
<script type="text/javascript" src="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;even.js" ></script>
202+
203+
</body>
204+
205+
</html>

0 commit comments

Comments
 (0)