2

While working on something like laravel, I end up creating the same view files index.blade.php, create.blade.php, show.blade.php within different folders like views/articles, views/comments, etc using the nerdTree mostly.

Is there a way to create the files from the command mode or through any plugin, for which i can create a key mapping to speed up things ?

2
  • 2
    How about something like :!touch views/{articles,comments}/{index,create,show}.blade.php? Oct 16, 2017 at 15:06
  • @Rastapopoulos thats a nice one, thanx! Oct 18, 2017 at 12:59

2 Answers 2

5

You can create a bunch of filenamed buffers from within vim using :argadd:

:argadd dir1/index.blade.php dir2/create.blade.php foo/show.blade.php 

You can also use the syntax

:argadd dir/{foo,bar}.php

From there, you can switch between buffers using :next/:Next, :buffer or any other way.

Note: vim does not default write the empty buffers to disk unless you explicitly :w them. You can easily create them all on disk using:

:argdo w

The plugin vim-projectionist is designed for this use case:

https://github.com/tpope/vim-projectionist

and the vim-laravel plugin already has support for vim-projectionist

https://github.com/noahfrederick/vim-laravel

0
2

You could do something like this:

command! -nargs=* MakeLaravelFiles call MakeLaravelFiles()
function! MakeLaravelFiles()
  !touch /path/to/first/file /path/to/second/file /path/to/third/file
endfunction

And then setup a keymapping to that function, aka

nnoremap <silent> <leader>ml :MakeLaravelFiles<CR>

(Note: this snippet creates blank files, but you can use any CLI command you prefer instead of touch)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.