Skip to content

Commit cf2dae4

Browse files
committed
Add BashMakeFunction
1 parent a3fd158 commit cf2dae4

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

bash-refactor.vim

+33
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
1+
function! BashMakeFunction()
2+
" save the name under curson in the "a" register
3+
normal! "ayiw
4+
" write the function
5+
" start inserting above the line
6+
normal! O
7+
" paste the name of the function (from the "a" register)
8+
" now we have: function-name
9+
normal! "ap
10+
" append the "()" and the "{"
11+
" now we have: function-name() {
12+
normal! a() {
13+
" add a line with the semicolon (null command in Bash)
14+
" now we have:
15+
" function-name() {
16+
" :
17+
normal! o:
18+
" add the closing brace
19+
" now we have:
20+
" function-name() {
21+
" :
22+
" }
23+
normal! o}
24+
" dedent if necessary the closing brace
25+
" now we have:
26+
" function-name() {
27+
" :
28+
" }
29+
normal! <<
30+
endfunction
31+
32+
nnoremap ,mf :call BashMakeFunction()<cr>
33+
134
function! BashExtractVariable()
235
let name = input("Variable name: ")
336
if name == ''

0 commit comments

Comments
 (0)