aboutsummaryrefslogtreecommitdiff
path: root/posts
diff options
context:
space:
mode:
Diffstat (limited to 'posts')
-rw-r--r--posts/bash_harder_with_vim.md57
1 files changed, 57 insertions, 0 deletions
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