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