I 开发者_运维问答want to add a shortcut like I type :open_my_document, it become :e /var/book/document.txt. how to?
If you want to create a custom command, use :command:
:command Open_my_document e /var/book/document.txt
Then you can use:
:Open_my_document
Normally you can just type :Ope and then hit tab and vim will complete the full command name.
Note that your command needs to start with a capital letter because only built-in vim commands can start with lower-case letters.
I think you might be looking for something like :h cabbr or :h cmap.
If you use cabbr, your text will not change once you enter your custom command. If you use cmap, it will. It's easier to just try both out to see which you'd rather use.
I don't know advantages/disadvantages of one or the other, personally, I use cmap.
Add this to your .vimrc:
map :open_my_document :e /var/book/document.txt
加载中,请稍侯......
精彩评论