blob: 4d60831a7a91c8ed853fc55941d107ffb911c854 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
Bash is tricky, don't let your editor get in your way. Here's a couple of neat
additions you could make to your `vimrc` for a better shell programming
experience.
* * *
#### Man pages inside vim
Source this script to get started:
```
runtime ftplugin/man.vim
```
Now, you can open manpages inside vim with `:Man`! It adds nicer syntax highlighting
and the ability to jump around with `Ctrl-]` and `Ctrl-T`.
By default, the manpage is opened in a horizontal split, I prefer using a new tab:
```
let g:ft_man_open_mode = 'tab'
```
* * *
#### Scratchpad to test your commands
I often test my `sed` substitutions, here is
a sample from the script used to generate this site:
```
# a substitution to convert snake_case to Title Case With Spaces
echo "$1" | sed -E -e "s/\..+$//g" -e "s/_(.)/ \u\1/g" -e "s/^(.)/\u\1/g"
```
Instead of dropping into a new shell, just test it out directly from vim!
- Yank the line into a register:
```
yy
```
- Paste it into the command-line window:
```
q:p
```
- Make edits as required:
```
syntax off # previously run commands
edit index.html # in a buffer!
w | so %
!echo "new_post.md" | sed -E -e "s/\..+$//g" --snip--
^--- note the use of '!'
```
- Hit enter with the cursor on the line containing your command!
```
$ vim
New Post # output
Press ENTER or type command to continue
```
|