DEV Community

Cover image for Using vim as a laravel/phpstorm developer

Posted on

Using vim as a laravel/phpstorm developer

These are my quick notes on how to start seriously using vim as a laravel developer. My goal is to replace phpstorm w/ vim and match the feature set. For what I'm doing now, microservices in laravel/php, phpstorm is struggling to keep up.

My apologies they're a bit of a mess as they're undergoing, but wanted to get them out there if anyone has some feedback or suggestions I'd love to hear it!
Screenshot of VIM Setup underway

# Using vim as a laravel developer
Ok, using vim as a phpstorm replacment, this is prettyyyy close.

Here are the steps and the useful parts to know.

# First things first, install awesome-vim, this gets 90% of the stuff you need and its maintained
git clone --depth=1 ~/.vim_runtime
sh ~/.vim_runtime/

# Next I'd say you're going to want phpunit baked in and here is an awesome plugin for that:
git clone ~/.vim_runtime/my_plugins/phpunit.vim

# Run inside vim: -- this will let you click and drag panes to resize or jump between (learning vim more and being able to jump panes
# makes this unecessary, but i'm not that good yet.)
:set mouse=a

# So now some sections on easy key commands/shortcuts

## Splitting VIM screen Horizontally and Vertically
To open a new VIM window next to the existing one, press <Ctrl>+<w> then press <v>.

## Move panes around vim (left/right or top/bottom)
Ctrl w + L - Move the current window to the "far right"
Ctrl w + H - Move the current window to the "far left"
Ctrl w + J - Move the current window to the "very bottom"
Ctrl w + K - Move the current window to the "very top"

## Copying everything into clipboard

## Indenting all the code
# Still need to look into a more serious formatter like:

# AwesomeVIM Leader Key Shortcut
You'll see vim plugins mention <leader>, that <leader> for awesome view is "," so whenever you see leader hit that key.

## phpunit
### Set the path of phpunit (most cases for me, vendor/bin/phpunit)
let g:phpunit_bin = 'phpunit'

### Shortcuts
<leader>ta - Run all test cases
<leader>ts - Switch between source & test file
<leader>tf - Run current test case class

# Folding
`zo` to open folding
`zc` to close folding

# NerdTREE
<leader>nn - Toggles NerdTREE
While inside NerdTREE hit "m" to do a number of modifications from renaming, deleting or adding files.

# Terminal
Typing ":term" will open a terminal pane similar to phpstorm.

Of course you can reference for more tips and tricks, such as <leader>w to write a file or <Ctrl+f> to fuzzy search for a file.
Enter fullscreen mode Exit fullscreen mode

I'd like to make a video to accompany this setup to better describe how to use vim in this way so let me know if that's anything you'd like to see and best of luck in the new vim setup!

Discussion (2)

phantas0s profile image
Matthieu Cneude

Interesting stuff. I wrote an article for Vim for PHP developer a while ago. Most of the tools are still relevant though:

gjrdiesel profile image
Justin Author

This is awesome, thanks for sharing!