使用Vim运行自定义命令



我想在Vim中创建一个artisan命令,这样我就可以执行以下操作:

:artisan make:migration create_blah_table --create=blah

并让它运行以下内容:

ssh -t vagrant "cd /var/www && php artisan make:migration create_blah_table --create=blah"

这可能吗?

更新

make:migration create_blah_table --create=blah比特可以是任何东西。

参见:help user-commands:

It is possible to define your own Ex commands.  A user-defined command can act
just like a built-in command (it can have a range or arguments, arguments can
be completed as filenames or buffer names, etc), except that when the command
is executed, it is transformed into a normal Ex command and then executed.
For starters: See section |40.2| in the user manual.
          *E183* *E841* *user-cmd-ambiguous*
All user defined commands must start with an uppercase letter, to avoid
confusion with builtin commands. 

您想要:command

:com[mand][!] [{attr}...] {cmd} {rep}
                        Define a user command.  The name of the command is
                        {cmd} and its replacement text is {rep}.  The command's
                        attributes (see below) are {attr}.  If the command
                        already exists, an error is reported, unless a ! is
                        specified, in which case the command is redefined.

你可以把它放在你的~/.vimrc:中

command -nargs=* Artisan !ssh -t vagrant "cd /var/www && php artisan <args>"

然后在ex模式下使用:Artisan make:migration create_blah_table --create=blah命令。

最新更新