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