Skip to content

Navigation Commands

Noah Frederick edited this page Feb 27, 2021 · 12 revisions

Built-in Navigation Commands

Laravel.vim provides navigation commands for editing files based on type. For example, you can use :Econtroller FooController to edit app/Http/Controllers/FooController.php and :Econfig app to edit config/app.php. Each navigation command offers completion for the given resource type.

The E stands for edit. You also get S, V, and T variants that split, vsplit, and tabedit. These commands rely on projectionist.vim (see Requirements):

Command Applies to...
:Easset Anything under resources/assets/
:Ebootstrap Bootstrap files in boostrap/
:Ecast Eloquent attribute casts
:Echannel Broadcast channels
:Ecommand Console commands
:Ecomponent Blade components
:Econfig Configuration files
:Econtroller HTTP controllers
:Edoc The README.md file
:Eenv Your .env and .env.example
:Eevent Events
:Eexception Exceptions
:Efactory Model factories
:Ejob Jobs
:Elanguage Messages/translations
:Elib All class files under app/
:Elistener Event listeners
:Email Mailables
:Emiddleware HTTP middleware
:Emigration Database migrations
:Emodel Models
:Enotification Notifications
:Eobserver Eloquent event observers
:Epolicy Auth policies
:Eprovider Service providers
:Erequest HTTP form requests
:Eresource HTTP resources
:Eroutes HTTP routes files
:Erule Validation rules
:Eseeder Database seeders
:Etest All class files under tests/
:Eview Blade templates

† Or :Econsole and :Ecommand, respectively, for Laravel 5.0.

Some navigation commands provide intelligent defaults when you don't provide an argument. For example, from a routes file, :Eprovider without argument takes you to app/Providers/RouteServiceProvider.php.

Adding Your Own

You can create your own custom navigation commands for Laravel projects. For example, to edit log files with :Elog, add the following to your .vimrc or init.vim:

augroup init_laravel
  autocmd!
  autocmd User ProjectionistDetect
        \ if exists('b:laravel_root') |
        \   call projectionist#append(b:laravel_root, {
        \     'storage/logs/*.log': { 'type': 'log' },
        \     'storage/logs/laravel.log': { 'type': 'log' }
        \   }) |
        \ endif
augroup END

See :help projectionist for further documentation on creating and using navigation commands.

Clone this wiki locally