Although I have been using Vim for quite some time now, I am still a novice when it comes to customizing it. I am not sure if what I have in mind can be done. Here what I would like to do: When writing a bash script I have a template to comment a function
1 #!/bin/bash
2
3 ###########################################################
4 # template
5 # globals:
6 # none
7 # returns:
8 # none
9 ###########################################################
10
11
12 my_function () {
13 ...
What I am currently doing is to position the cursor at line 11
and then issue the command:
:3,9y
This yanks lines 3 to 9 into the buffer. Then I hit p
and it pastes the lines after the cursor. I would like to simplify this process. Can I achieve the above behavior by defining something like a macro? Ideally I would define it the .vimrc
file and not rely on the script to have the template exaclty at lines 3 through 9.
You could place the text of your banner in a named register:
let @c = "###########################################################\n"
let @c .= "# template\n"
let @c .= "# globals:\n"
let @c .= "# none\n"
let @c .= "# returns:\n"
let @c .= "# none\n"
let @c .= "###########################################################"
and put it with:
"cp
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments