I’m new to mvim and I’m not sure how to use commands that have been saved in my vimrc file like the following:
"Load the current buffer in Chrome - Mac specific.
abbrev chrome :! open -a Google\ Chrome %:p<cr>
(note: This was originally:
"Load the current buffer in Chrome - Mac specific.
abbrev ff :! open -a FireFox.app %:p<cr>
)
I’m just confused as how this abbrev works all together and couldn’t find an answer on google :\ Maybe someone here could help?
These lines create an abbreviation for a commonly used command. In this case, it is creating an abbreviation for opening the current buffer in a particular application. For instance if you were working on a file called
index.htmland you entered the command:chromein vim, it would open index.html in Chrome.For the three major Mac browsers, use the following lines in your
.vimrcfile:This works because the
:!at the beginning of each abbreviation definition tells vim to execute a shell command. In these cases, the shell command isopen -a [WHICHEVER_BROSWER].appusing the current buffer%:p.Here is some further reading: