aboutsummaryrefslogtreecommitdiff
path: root/docs/posts/bash_harder_with_vim.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/posts/bash_harder_with_vim.html')
-rw-r--r--docs/posts/bash_harder_with_vim.html86
1 files changed, 0 insertions, 86 deletions
diff --git a/docs/posts/bash_harder_with_vim.html b/docs/posts/bash_harder_with_vim.html
deleted file mode 100644
index 54ab982..0000000
--- a/docs/posts/bash_harder_with_vim.html
+++ /dev/null
@@ -1,86 +0,0 @@
1<!DOCTYPE html>
2<html lang="en">
3 <head>
4 <link rel="stylesheet" href="/style.css">
5 <meta charset="UTF-8">
6 <meta name="viewport" content="initial-scale=1">
7 <meta content="#ffffff" name="theme-color">
8 <meta name="HandheldFriendly" content="true">
9 <meta property="og:title" content="nerdypepper">
10 <meta property="og:type" content="website">
11 <meta property="og:description" content="a static site {for, by, about} me ">
12 <meta property="og:url" content="https://nerdypepper.tech">
13 <body>
14 <div class="posts">
15 <div class="post">
16 <div class="date">31/07 2019</div>
17 <span style="font-size: 2rem; font-weight: 600">
18 Bash Harder With Vim
19 </span>
20 <div class="post-text">
21 <p>Bash is tricky, don&#8217;t let your editor get in your way. Here&#8217;s a couple of neat
22additions you could make to your <code>vimrc</code> for a better shell programming
23experience.</p>
24
25<hr/>
26
27<h4 id="Man%20pages%20inside%20vim">Man pages inside vim</h4>
28
29<p>Source this script to get started: </p>
30
31<pre><code>runtime ftplugin/man.vim
32</code></pre>
33
34<p>Now, you can open manpages inside vim with <code>:Man</code>! It adds nicer syntax highlighting
35and the ability to jump around with <code>Ctrl-]</code> and <code>Ctrl-T</code>.</p>
36
37<p>By default, the manpage is opened in a horizontal split, I prefer using a new tab:</p>
38
39<pre><code>let g:ft_man_open_mode = &#39;tab&#39;
40</code></pre>
41
42<hr/>
43
44<h4 id="Scratchpad%20to%20test%20your%20commands">Scratchpad to test your commands</h4>
45
46<p>I often test my <code>sed</code> substitutions, here is
47a sample from the script used to generate this site: </p>
48
49<pre><code># a substitution to convert snake_case to Title Case With Spaces
50echo &quot;$1&quot; | sed -E -e &quot;s/\..+$//g&quot; -e &quot;s/_(.)/ \u\1/g&quot; -e &quot;s/^(.)/\u\1/g&quot;
51</code></pre>
52
53<p>Instead of dropping into a new shell, just test it out directly from vim!</p>
54
55<ul>
56<li><p>Yank the line into a register:</p>
57
58<pre><code>yy
59</code></pre></li>
60<li><p>Paste it into the command-line window:</p>
61
62<pre><code>q:p
63</code></pre></li>
64<li><p>Make edits as required:</p>
65
66<pre><code>syntax off # previously run commands
67edit index.html # in a buffer!
68w | so %
69!echo &quot;new_post.md&quot; | sed -E -e &quot;s/\..+$//g&quot; --snip--
70^--- note the use of &#39;!&#39;
71</code></pre></li>
72<li><p>Hit enter with the cursor on the line containing your command!</p>
73
74<pre><code>$ vim
75New Post # output
76Press ENTER or type command to continue
77</code></pre></li>
78</ul>
79
80 </div>
81 <a href="/index.html" class="post-end-link">← Back</a>
82 <div class="separator"></div>
83 </div>
84 </div>
85 </body>
86</html>