Skip to content

Commit 186dc97

Browse files
added eighth Vim tip
1 parent 5cac28f commit 186dc97

File tree

9 files changed

+267
-7
lines changed

9 files changed

+267
-7
lines changed

README.md

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

5454
## Tips
5555

56+
* [Vim tip 8: join lines](https://learnbyexample.github.io/tips/vim-tip-8/)
5657
* [CLI tip 9: awk paragraph mode](https://learnbyexample.github.io/tips/cli-tip-9/)
5758
* [Python tip 9: applying set-like operations for dictionaries](https://learnbyexample.github.io/tips/python-tip-9/)
5859
* [Vim tip 7: changing case in Normal mode](https://learnbyexample.github.io/tips/vim-tip-7/)

atom.xml

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,37 @@
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-05-03T00:00:00+00:00</updated>
8+
<updated>2022-05-04T00:00:00+00:00</updated>
99
<id>https://learnbyexample.github.io/atom.xml</id>
10+
<entry xml:lang="en">
11+
<title>Vim tip 8: join lines</title>
12+
<published>2022-05-04T00:00:00+00:00</published>
13+
<updated>2022-05-04T00:00:00+00:00</updated>
14+
<link href="https://learnbyexample.github.io/tips/vim-tip-8/" type="text/html"/>
15+
<id>https://learnbyexample.github.io/tips/vim-tip-8/</id>
16+
<content type="html">&lt;p&gt;In Normal mode, you can join lines using &lt;code&gt;J&lt;&#x2F;code&gt; and &lt;code&gt;gJ&lt;&#x2F;code&gt; commands. These differ in how the end-of-line character and indentation at the start of lines being joined are handled.&lt;&#x2F;p&gt;
17+
&lt;ul&gt;
18+
&lt;li&gt;&lt;kbd&gt;J&lt;&#x2F;kbd&gt; joins the current line and the next line
19+
&lt;ul&gt;
20+
&lt;li&gt;the deleted &lt;code&gt;&amp;lt;EOL&amp;gt;&lt;&#x2F;code&gt; character is replaced with a space (unless there are trailing spaces or the next line starts with a &lt;code&gt;)&lt;&#x2F;code&gt; character)&lt;&#x2F;li&gt;
21+
&lt;li&gt;indentation from the lines being joined are removed, &lt;em&gt;except the current line&lt;&#x2F;em&gt;&lt;&#x2F;li&gt;
22+
&lt;&#x2F;ul&gt;
23+
&lt;&#x2F;li&gt;
24+
&lt;li&gt;&lt;kbd&gt;3J&lt;&#x2F;kbd&gt; joins the current line and next two lines with one space in between the lines&lt;&#x2F;li&gt;
25+
&lt;li&gt;&lt;kbd&gt;gJ&lt;&#x2F;kbd&gt; joins the current line and the next line
26+
&lt;ul&gt;
27+
&lt;li&gt;&lt;code&gt;&amp;lt;EOL&amp;gt;&lt;&#x2F;code&gt; character is deleted (space character won&#x27;t be added)&lt;&#x2F;li&gt;
28+
&lt;li&gt;indentation won&#x27;t be removed&lt;&#x2F;li&gt;
29+
&lt;&#x2F;ul&gt;
30+
&lt;&#x2F;li&gt;
31+
&lt;&#x2F;ul&gt;
32+
&lt;p&gt;&lt;img src=&quot;&#x2F;images&#x2F;info.svg&quot; alt=&quot;info&quot; &#x2F;&gt; &lt;code&gt;joinspaces&lt;&#x2F;code&gt;, &lt;code&gt;cpoptions&lt;&#x2F;code&gt; and &lt;code&gt;formatoptions&lt;&#x2F;code&gt; settings will affect the behavior of these commands. See &lt;a href=&quot;https:&#x2F;&#x2F;vimhelp.org&#x2F;change.txt.html#J&quot;&gt;:h J&lt;&#x2F;a&gt; and scroll down for more details.&lt;&#x2F;p&gt;
33+
&lt;p&gt;&lt;strong&gt;Video demo&lt;&#x2F;strong&gt;:&lt;&#x2F;p&gt;
34+
&lt;p align=&quot;center&quot;&gt;&lt;iframe width=&quot;560&quot; height=&quot;315&quot; src=&quot;https:&#x2F;&#x2F;www.youtube.com&#x2F;embed&#x2F;rubhH6v4lN0&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;
35+
&lt;br&gt;
36+
&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;
37+
</content>
38+
</entry>
1039
<entry xml:lang="en">
1140
<title>CLI tip 9: awk paragraph mode</title>
1241
<published>2022-04-27T00:00:00+00:00</published>
@@ -3232,7 +3261,7 @@ $ diff &lt;&#x2F;span&gt;&lt;span style=&quot;color:#72ab00;&quot;&gt;-&lt;&#x2F
32323261
<entry xml:lang="en">
32333262
<title>Customizing pandoc to generate beautiful pdf and epub from markdown</title>
32343263
<published>2020-07-21T00:00:00+00:00</published>
3235-
<updated>2022-01-25T00:00:00+00:00</updated>
3264+
<updated>2022-05-04T00:00:00+00:00</updated>
32363265
<link href="https://learnbyexample.github.io/customizing-pandoc/" type="text/html"/>
32373266
<id>https://learnbyexample.github.io/customizing-pandoc/</id>
32383267
<content type="html">&lt;p&gt;Either you&#x27;ve already heard of &lt;code&gt;pandoc&lt;&#x2F;code&gt; or if you have searched online for &lt;code&gt;markdown&lt;&#x2F;code&gt; to &lt;code&gt;pdf&lt;&#x2F;code&gt; or similar, you are sure to come across &lt;code&gt;pandoc&lt;&#x2F;code&gt;. This tutorial will help you use &lt;code&gt;pandoc&lt;&#x2F;code&gt; to generate &lt;code&gt;pdf&lt;&#x2F;code&gt; and &lt;code&gt;epub&lt;&#x2F;code&gt; from a &lt;a href=&quot;https:&#x2F;&#x2F;github.github.com&#x2F;gfm&#x2F;&quot;&gt;GitHub style markdown&lt;&#x2F;a&gt; file. The main motivation for this blog post is to highlight what customizations I did to generate &lt;code&gt;pdf&lt;&#x2F;code&gt; and &lt;code&gt;epub&lt;&#x2F;code&gt; versions for &lt;a href=&quot;https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;books&#x2F;&quot;&gt;self-publishing my ebooks&lt;&#x2F;a&gt;. It wasn&#x27;t easy to arrive at the set-up I ended up with, so I hope this will be useful for those looking to use &lt;code&gt;pandoc&lt;&#x2F;code&gt; to generate &lt;code&gt;pdf&lt;&#x2F;code&gt; and &lt;code&gt;epub&lt;&#x2F;code&gt; formats. This guide is specifically aimed at technical books that has code snippets.&lt;&#x2F;p&gt;
@@ -3282,7 +3311,12 @@ Implies --standalone.&lt;&#x2F;p&gt;
32823311
&lt;pre style=&quot;background-color:#f5f5f5;&quot;&gt;
32833312
&lt;code&gt;&lt;span style=&quot;color:#5597d6;&quot;&gt;$&lt;&#x2F;span&gt;&lt;span style=&quot;color:#1f1f1f;&quot;&gt; pandoc sample_1.md&lt;&#x2F;span&gt;&lt;span style=&quot;color:#5597d6;&quot;&gt; -f&lt;&#x2F;span&gt;&lt;span style=&quot;color:#1f1f1f;&quot;&gt; gfm&lt;&#x2F;span&gt;&lt;span style=&quot;color:#5597d6;&quot;&gt; -H&lt;&#x2F;span&gt;&lt;span style=&quot;color:#1f1f1f;&quot;&gt; chapter_break.tex&lt;&#x2F;span&gt;&lt;span style=&quot;color:#5597d6;&quot;&gt; -o&lt;&#x2F;span&gt;&lt;span style=&quot;color:#1f1f1f;&quot;&gt; sample_1_chapter_break.pdf
32843313
&lt;&#x2F;span&gt;&lt;&#x2F;code&gt;&lt;&#x2F;pre&gt;
3285-
&lt;p&gt;You can add further customization to headings, for example use &lt;code&gt;\sectionfont{\underline\clearpage}&lt;&#x2F;code&gt; to underline chapter names or &lt;code&gt;\sectionfont{\LARGE\clearpage}&lt;&#x2F;code&gt; to allow chapter names to get even bigger. Here&#x27;s some more links to read about various customizations:&lt;&#x2F;p&gt;
3314+
&lt;p&gt;You can add further customization to headings, for example:&lt;&#x2F;p&gt;
3315+
&lt;ul&gt;
3316+
&lt;li&gt;&lt;code&gt;\sectionfont{\underline\clearpage}&lt;&#x2F;code&gt; to underline chapter names&lt;&#x2F;li&gt;
3317+
&lt;li&gt;&lt;code&gt;\sectionfont{\LARGE\clearpage}&lt;&#x2F;code&gt; to allow chapter names to get even bigger&lt;&#x2F;li&gt;
3318+
&lt;&#x2F;ul&gt;
3319+
&lt;p&gt;Here are some more links to read about various customizations:&lt;&#x2F;p&gt;
32863320
&lt;ul&gt;
32873321
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;tex.stackexchange.com&#x2F;questions&#x2F;1455&#x2F;how-to-set-the-font-for-a-section-title-and-chapter-etc&quot;&gt;tex.stackexchange: section fonts&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;
32883322
&lt;li&gt;&lt;a href=&quot;https:&#x2F;&#x2F;tex.stackexchange.com&#x2F;questions&#x2F;230730&#x2F;section-coming-up-as-undefined-when-using-sectsty&quot;&gt;tex.stackexchange: section colors&lt;&#x2F;a&gt;&lt;&#x2F;li&gt;

customizing-pandoc/index.html

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,12 @@ <h2 id="chapter-breaks">Chapter breaks<a class="zola-anchor" href="#chapter-brea
255255
<pre style="background-color:#f5f5f5;">
256256
<code><span style="color:#5597d6;">$</span><span style="color:#1f1f1f;"> pandoc sample_1.md</span><span style="color:#5597d6;"> -f</span><span style="color:#1f1f1f;"> gfm</span><span style="color:#5597d6;"> -H</span><span style="color:#1f1f1f;"> chapter_break.tex</span><span style="color:#5597d6;"> -o</span><span style="color:#1f1f1f;"> sample_1_chapter_break.pdf
257257
</span></code></pre>
258-
<p>You can add further customization to headings, for example use <code>\sectionfont{\underline\clearpage}</code> to underline chapter names or <code>\sectionfont{\LARGE\clearpage}</code> to allow chapter names to get even bigger. Here's some more links to read about various customizations:</p>
258+
<p>You can add further customization to headings, for example:</p>
259+
<ul>
260+
<li><code>\sectionfont{\underline\clearpage}</code> to underline chapter names</li>
261+
<li><code>\sectionfont{\LARGE\clearpage}</code> to allow chapter names to get even bigger</li>
262+
</ul>
263+
<p>Here are some more links to read about various customizations:</p>
259264
<ul>
260265
<li><a href="https://tex.stackexchange.com/questions/1455/how-to-set-the-font-for-a-section-title-and-chapter-etc">tex.stackexchange: section fonts</a></li>
261266
<li><a href="https://tex.stackexchange.com/questions/230730/section-coming-up-as-undefined-when-using-sectsty">tex.stackexchange: section colors</a></li>

sitemap.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
</url>
3333
<url>
3434
<loc>https://learnbyexample.github.io/customizing-pandoc/</loc>
35-
<lastmod>2022-01-25</lastmod>
35+
<lastmod>2022-05-04</lastmod>
3636
</url>
3737
<url>
3838
<loc>https://learnbyexample.github.io/duplicates-irrespective-field-order/</loc>
@@ -443,6 +443,10 @@
443443
<loc>https://learnbyexample.github.io/tips/vim-tip-7/</loc>
444444
<lastmod>2022-04-12</lastmod>
445445
</url>
446+
<url>
447+
<loc>https://learnbyexample.github.io/tips/vim-tip-8/</loc>
448+
<lastmod>2022-05-04</lastmod>
449+
</url>
446450
<url>
447451
<loc>https://learnbyexample.github.io/vim-reference-guide-announcement/</loc>
448452
<lastmod>2022-03-15</lastmod>

tags/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@
379379

380380
<a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;tags&#x2F;tip&#x2F;">
381381
tip
382-
<span class="count">25</span>
382+
<span class="count">26</span>
383383
</a>
384384

385385
<a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;tags&#x2F;tutorial&#x2F;">
@@ -389,7 +389,7 @@
389389

390390
<a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;tags&#x2F;vim&#x2F;">
391391
vim
392-
<span class="count">12</span>
392+
<span class="count">13</span>
393393
</a>
394394

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

tags/tip/index.html

Lines changed: 7 additions & 0 deletions
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-05-04</span>
129+
<span class="taxonomy__item__title">
130+
<a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;tips&#x2F;vim-tip-8&#x2F;">Vim tip 8: join lines</a>
131+
</span>
132+
</div>
133+
127134
<div class="taxonomy__item">
128135
<span class="taxonomy__item__time">2022-04-27</span>
129136
<span class="taxonomy__item__title">

tags/vim/index.html

Lines changed: 7 additions & 0 deletions
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-05-04</span>
129+
<span class="taxonomy__item__title">
130+
<a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;tips&#x2F;vim-tip-8&#x2F;">Vim tip 8: join lines</a>
131+
</span>
132+
</div>
133+
127134
<div class="taxonomy__item">
128135
<span class="taxonomy__item__time">2022-04-12</span>
129136
<span class="taxonomy__item__title">

tips/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ <h2 id="command-line-tools-penguin"><p style="color: #ff6600"><a name="command-l
152152
<hr>
153153
<h2 id="vim-memo"><p style="color: #ff6600"><a name="vim"></a>Vim 📝</h2>
154154
<ul>
155+
<li><a href="https://learnbyexample.github.io/tips/vim-tip-8/">Vim tip 8: join lines</a></li>
155156
<li><a href="https://learnbyexample.github.io/tips/vim-tip-7/">Vim tip 7: changing case in Normal mode</a></li>
156157
<li><a href="https://learnbyexample.github.io/tips/vim-tip-6/">Vim tip 6: search word nearest to the cursor</a></li>
157158
<li><a href="https://learnbyexample.github.io/tips/vim-tip-5/">Vim tip 5: jumping back and forth in Normal mode</a></li>

tips/vim-tip-8/index.html

Lines changed: 201 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,201 @@
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 8: join lines</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-8&#x2F;">Vim tip 8: join lines</a>
132+
</h1>
133+
<div class="post__meta">
134+
<span class="post__time">2022-05-04</span>
135+
136+
</div>
137+
</header>
138+
139+
<div class="post-content">
140+
<p>In Normal mode, you can join lines using <code>J</code> and <code>gJ</code> commands. These differ in how the end-of-line character and indentation at the start of lines being joined are handled.</p>
141+
<ul>
142+
<li><kbd>J</kbd> joins the current line and the next line
143+
<ul>
144+
<li>the deleted <code>&lt;EOL&gt;</code> character is replaced with a space (unless there are trailing spaces or the next line starts with a <code>)</code> character)</li>
145+
<li>indentation from the lines being joined are removed, <em>except the current line</em></li>
146+
</ul>
147+
</li>
148+
<li><kbd>3J</kbd> joins the current line and next two lines with one space in between the lines</li>
149+
<li><kbd>gJ</kbd> joins the current line and the next line
150+
<ul>
151+
<li><code>&lt;EOL&gt;</code> character is deleted (space character won't be added)</li>
152+
<li>indentation won't be removed</li>
153+
</ul>
154+
</li>
155+
</ul>
156+
<p><img src="/images/info.svg" alt="info" /> <code>joinspaces</code>, <code>cpoptions</code> and <code>formatoptions</code> settings will affect the behavior of these commands. See <a href="https://vimhelp.org/change.txt.html#J">:h J</a> and scroll down for more details.</p>
157+
<p><strong>Video demo</strong>:</p>
158+
<p align="center"><iframe width="560" height="315" src="https://www.youtube.com/embed/rubhH6v4lN0" title="YouTube video player" frameborder="0" allow="accelerometer; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe></p>
159+
<br>
160+
<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>
161+
162+
</div>
163+
164+
165+
166+
167+
<div class="post-footer">
168+
169+
170+
<div class="post-tags">
171+
172+
<a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;tags&#x2F;vim&#x2F;">#vim</a>
173+
174+
<a href="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;tags&#x2F;tip&#x2F;">#tip</a>
175+
176+
</div>
177+
178+
179+
180+
181+
182+
</div>
183+
184+
185+
186+
</article>
187+
188+
189+
</div>
190+
</main>
191+
192+
193+
194+
</div>
195+
196+
197+
<script type="text/javascript" src="https:&#x2F;&#x2F;learnbyexample.github.io&#x2F;even.js" ></script>
198+
199+
</body>
200+
201+
</html>

0 commit comments

Comments
 (0)