aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNerdyPepper <[email protected]>2019-07-31 16:49:46 +0100
committerNerdyPepper <[email protected]>2019-07-31 16:49:46 +0100
commitbe70d338e35209c94ce875734fe483b21f98b5b1 (patch)
tree5e4ede704c62fc9bbf8ee6e485dd4e47d80c60b5
parent502f7102495cf7919b3be67d1bec43a7f3591ee1 (diff)
new post; bash harder with vim
-rw-r--r--docs/index.html60
-rw-r--r--posts/bash_harder_with_vim.md57
2 files changed, 116 insertions, 1 deletions
diff --git a/docs/index.html b/docs/index.html
index 70fd4c8..766219d 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -26,9 +26,67 @@ function showPost(id) {
26 26
27 27
28 <div class="post"> 28 <div class="post">
29 <div class="date">31/07 2019</div>
30 <a href="#bash_harder_with_vim.md" class="post-link" onClick="showPost('bash_harder_with_vim.md')">Bash Harder With Vim</a>
31 <div id="bash_harder_with_vim.md" class="post-text" style="display: block">
32 <p>Bash is tricky, dont let your editor get in your way. Here&#8217;s a couple of neat
33addtions you could make to your <code>vimrc</code> for a better shell programming
34experience.</p>
35
36<p><strong>Man pages inside vim</strong>. Source this script to get started: </p>
37
38<pre><code>runtime ftplugin/man.vim
39</code></pre>
40
41<p>Now, you can open manpages inside vim with <code>:Man</code>! It adds nicer syntax highlighting
42and the ability to jump around with <code>Ctrl-]</code> and <code>Ctrl-T</code>.</p>
43
44<p>By default, the manpage is opened in a horizontal split, I prefer using a new tab:</p>
45
46<pre><code>let g:ft_man_open_mode = &#39;tab&#39;
47</code></pre>
48
49<p><strong>Scratchpad to test your commands</strong>. I often test my <code>sed</code> substitutions, here is
50a sample from the script used to generate this site: </p>
51
52<pre><code># a substitution to convert snake_case to Title Case With Spaces
53echo &quot;$1&quot; | sed -E -e &quot;s/\..+$//g&quot; -e &quot;s/_(.)/ \u\1/g&quot; -e &quot;s/^(.)/\u\1/g&quot;
54</code></pre>
55
56<p>Instead of dropping into a new shell, just test it out directly from vim!</p>
57
58<ul>
59<li><p>Yank the link into a register:</p>
60
61<pre><code>yy
62</code></pre></li>
63<li><p>Paste it into the command-line window:</p>
64
65<pre><code>q:p
66</code></pre></li>
67<li><p>Make edits as required:</p>
68
69<pre><code>syntax off # previously run commands
70edit index.html # in a buffer!
71w | so %
72echo &quot;new_post.md&quot; | sed -E -e &quot;s/\..+$//g&quot; -e &quot;s/_(.)/ \u\1/g&quot; -e &quot;s/^(.)/\u\1/g&quot;
73</code></pre></li>
74<li><p>Hit enter!</p>
75
76<pre><code>$ vim
77New Post # output
78Press ENTER or type command to continue
79</code></pre></li>
80</ul>
81 <a href="#bash_harder_with_vim.md" class="post-end-link" onClick="showPost('bash_harder_with_vim.md')">↑ Collapse</a>
82 <div class=separator></div>
83 </div>
84 </div>
85
86 <div class="post">
29 <div class="date">30/07 2019</div> 87 <div class="date">30/07 2019</div>
30 <a href="#hold_position!.md" class="post-link" onClick="showPost('hold_position!.md')">Hold Position!</a> 88 <a href="#hold_position!.md" class="post-link" onClick="showPost('hold_position!.md')">Hold Position!</a>
31 <div id="hold_position!.md" class="post-text" style="display: block"> 89 <div id="hold_position!.md" class="post-text" style="display: none">
32 <p>Often times, when I run a vim command that makes &#8220;big&#8221; changes to a file (a 90 <p>Often times, when I run a vim command that makes &#8220;big&#8221; changes to a file (a
33macro or a <code>:vimgrep</code> command) I lose my original position and feel disoriented.</p> 91macro or a <code>:vimgrep</code> command) I lose my original position and feel disoriented.</p>
34 92
diff --git a/posts/bash_harder_with_vim.md b/posts/bash_harder_with_vim.md
new file mode 100644
index 0000000..8dc4a50
--- /dev/null
+++ b/posts/bash_harder_with_vim.md
@@ -0,0 +1,57 @@
1Bash is tricky, dont let your editor get in your way. Here's a couple of neat
2addtions you could make to your `vimrc` for a better shell programming
3experience.
4
5**Man pages inside vim**. Source this script to get started:
6
7```
8runtime ftplugin/man.vim
9```
10Now, you can open manpages inside vim with `:Man`! It adds nicer syntax highlighting
11and the ability to jump around with `Ctrl-]` and `Ctrl-T`.
12
13By default, the manpage is opened in a horizontal split, I prefer using a new tab:
14
15```
16let g:ft_man_open_mode = 'tab'
17```
18
19
20**Scratchpad to test your commands**. I often test my `sed` substitutions, here is
21a sample from the script used to generate this site:
22
23```
24# a substitution to convert snake_case to Title Case With Spaces
25echo "$1" | sed -E -e "s/\..+$//g" -e "s/_(.)/ \u\1/g" -e "s/^(.)/\u\1/g"
26```
27Instead of dropping into a new shell, just test it out directly from vim!
28
29 - Yank the link into a register:
30
31 ```
32yy
33 ```
34
35 - Paste it into the command-line window:
36
37 ```
38q:p
39 ```
40
41 - Make edits as required:
42
43 ```
44syntax off # previously run commands
45edit index.html # in a buffer!
46w | so %
47echo "new_post.md" | sed -E -e "s/\..+$//g" -e "s/_(.)/ \u\1/g" -e "s/^(.)/\u\1/g"
48 ```
49
50 - Hit enter with the cursor on the line containing your command!
51
52 ```
53$ vim
54New Post # output
55Press ENTER or type command to continue
56 ```
57