Add a user defined vi editor command:
This will make it so that when the user types :Legend
in normal mode, a block of text is added under the cursor.
Step 1: Put this line into a file named ~/legend_header.txt`
this text will be added
Step 2: Put this command into your ~/.vimrc file (if the file doesn't exist, create it):
"The following command puts the contents of ~/legend_header.txt
"under the cursor when the user types ":Legend" in normal mode.
command Legend :r ~/legend_header.txt
Step 3: Restart vi for the changes to take effect. You're done.
Test it
Step 1: Open a new file in vi. Be in the default "normal mode" in vi. Type :Legend
Step 2: The contents of ~/legend_header.txt
should be added where the cursor is.
4if you are replacing an existing command, you need to use
command!
. – phyatt – 2017-01-12T20:00:53.290