aboutsummaryrefslogtreecommitdiff
path: root/docs/posts/bash_harder_with_vim
diff options
context:
space:
mode:
Diffstat (limited to 'docs/posts/bash_harder_with_vim')
-rw-r--r--docs/posts/bash_harder_with_vim/index.html92
1 files changed, 47 insertions, 45 deletions
diff --git a/docs/posts/bash_harder_with_vim/index.html b/docs/posts/bash_harder_with_vim/index.html
index 396fcfa..17c066a 100644
--- a/docs/posts/bash_harder_with_vim/index.html
+++ b/docs/posts/bash_harder_with_vim/index.html
@@ -37,60 +37,62 @@
37 Bash Harder With Vim 37 Bash Harder With Vim
38 </h1> 38 </h1>
39 <div class="post-text"> 39 <div class="post-text">
40 <p>Bash is tricky, don&#39;t let your editor get in your way. Here&#39;s a couple of neat 40 <!DOCTYPE html>
41additions you could make to your <code>vimrc</code> for a better shell programming 41<html xmlns="http://www.w3.org/1999/xhtml" lang="" xml:lang="">
42experience.</p> 42<head>
43 43 <meta charset="utf-8" />
44<h3 id="Man%20pages%20inside%20vim">Man pages inside vim</h3> 44 <meta name="generator" content="pandoc" />
45 45 <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes" />
46<p>Source this script to get started: </p> 46 <title>bash_harder_with_vim</title>
47 47 <style>
48<pre><code>runtime ftplugin&#47;man.vim 48 code{white-space: pre-wrap;}
49</code></pre> 49 span.smallcaps{font-variant: small-caps;}
50 50 span.underline{text-decoration: underline;}
51<p>Now, you can open manpages inside vim with <code>:Man</code>! It adds nicer syntax highlighting 51 div.column{display: inline-block; vertical-align: top; width: 50%;}
52and the ability to jump around with <code>Ctrl-]</code> and <code>Ctrl-T</code>.</p> 52 div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
53 53 ul.task-list{list-style: none;}
54 </style>
55 <!--[if lt IE 9]>
56 <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
57 <![endif]-->
58</head>
59<body>
60<p>Bash is tricky, don’t let your editor get in your way. Here’s a couple of neat additions you could make to your <code>vimrc</code> for a better shell programming experience.</p>
61<h3 id="man-pages-inside-vim">Man pages inside vim</h3>
62<p>Source this script to get started:</p>
63<pre><code>runtime ftplugin/man.vim</code></pre>
64<p>Now, you can open manpages inside vim with <code>:Man</code>! It adds nicer syntax highlighting and the ability to jump around with <code>Ctrl-]</code> and <code>Ctrl-T</code>.</p>
54<p>By default, the manpage is opened in a horizontal split, I prefer using a new tab:</p> 65<p>By default, the manpage is opened in a horizontal split, I prefer using a new tab:</p>
55 66<pre><code>let g:ft_man_open_mode = &#39;tab&#39;</code></pre>
56<pre><code>let g:ft_man_open_mode = &#39;tab&#39; 67<h3 id="scratchpad-to-test-your-commands">Scratchpad to test your commands</h3>
57</code></pre> 68<p>I often test my <code>sed</code> substitutions, here is a sample from the script used to generate this site:</p>
58
59<h3 id="Scratchpad%20to%20test%20your%20commands">Scratchpad to test your commands</h3>
60
61<p>I often test my <code>sed</code> substitutions, here is
62a sample from the script used to generate this site: </p>
63
64<pre><code># a substitution to convert snake_case to Title Case With Spaces 69<pre><code># a substitution to convert snake_case to Title Case With Spaces
65echo &#34;$1&#34; | sed -E -e &#34;s&#47;\..+$&#47;&#47;g&#34; -e &#34;s&#47;_(.)&#47; \u\1&#47;g&#34; -e &#34;s&#47;^(.)&#47;\u\1&#47;g&#34; 70echo &quot;$1&quot; | sed -E -e &quot;s/\..+$//g&quot; -e &quot;s/_(.)/ \u\1/g&quot; -e &quot;s/^(.)/\u\1/g&quot;</code></pre>
66</code></pre>
67
68<p>Instead of dropping into a new shell, just test it out directly from vim!</p> 71<p>Instead of dropping into a new shell, just test it out directly from vim!</p>
69
70<ul> 72<ul>
71<li><p>Yank the line into a register:</p> 73<li>Yank the line into a register:</li>
72 74</ul>
73<pre><code>yy 75<pre><code>yy</code></pre>
74</code></pre></li> 76<ul>
75<li><p>Paste it into the command-line window:</p> 77<li>Paste it into the command-line window:</li>
76 78</ul>
77<pre><code>q:p 79<pre><code>q:p</code></pre>
78</code></pre></li> 80<ul>
79<li><p>Make edits as required:</p> 81<li>Make edits as required:</li>
80 82</ul>
81<pre><code>syntax off # previously run commands 83<pre><code>syntax off # previously run commands
82edit index.html # in a buffer! 84edit index.html # in a buffer!
83w | so % 85w | so %
84!echo &#34;new_post.md&#34; | sed -E -e &#34;s&#47;\..+$&#47;&#47;g&#34; --snip-- 86!echo &quot;new_post.md&quot; | sed -E -e &quot;s/\..+$//g&quot; --snip--
85^--- note the use of &#39;!&#39; 87^--- note the use of &#39;!&#39;</code></pre>
86</code></pre></li> 88<ul>
87<li><p>Hit enter with the cursor on the line containing your command!</p> 89<li>Hit enter with the cursor on the line containing your command!</li>
88 90</ul>
89<pre><code>$ vim 91<pre><code>$ vim
90New Post # output 92New Post # output
91Press ENTER or type command to continue 93Press ENTER or type command to continue</code></pre>
92</code></pre></li> 94</body>
93</ul> 95</html>
94 96
95 </div> 97 </div>
96 98