r/PHP • • May 10 '19

Use Vim as a PHP IDE

https://spacevim.org/use-vim-as-a-php-ide/#.XNVEiDJCV24.reddit
55 Upvotes

126 comments sorted by

19

u/phantaso0s May 10 '19

I'm not a big fan of Vim-IDE-out-of-the-box. One of the big strength of Vim to me is: you can configure it depending on your precise needs / workflows.What you can't really do with something like PHPStorm.

That's why it's better to begin with the basic install of Vim and add what your really need.

I wrote an article where I explain every plugin you might need to build your own PHP editor / IDE: https://thevaluable.dev/vim-php-ide/

If you want to know why I switched from years with PHPStorm to Vim, here's the story: https://thevaluable.dev/phpstorm-vs-vim/

Hope it can help!

6

u/laygo3 May 10 '19

As I'm reading your conversion from PhpStorm to VIM, I'm at the part of you not being a touch typist. Being proficient at keyboard short cuts work just as well as VIM in PhpStorm. In fact, I can tell how much effort people put into being proficient with ANYTHING they come across by how much they user their mouse. Watching a co-worker highlight some text to copy and using his mouse with 80% of the operation drives me crazy. It's such a simple process (to me).

I would guess I can do some where between 70-80% of what is needed to be done without the need of my mouse in PhpStorm.

3

u/[deleted] May 10 '19

really, it's personal preference

get the job done and make sure you don't get a heart attack

2

u/laygo3 May 10 '19

As developers, we strive for efficiencies across the board:
- response times
- query times
- performance tuning
- etc

Yet, most won't try to figure out the most efficient way to use their tools? That's not a "personal preference".

2

u/[deleted] May 10 '19

that's definitely a preference

and vim can be the most efficient tool alive for some developers. Try to challenge this idea.

-2

u/2012-09-04 May 10 '19

I do routinely as a team lead.

3

u/fatboyxpc May 11 '19

The biggest difference between shortcuts in vim and other editors is composition vs straight memorization. You have to memorize weird shortcuts that don't make a lot of sense with Sublime, Atom, PHP Storm, etc. With vim, however, you only need to memorize a few fundamentals and you can start composing actions together. Example: to delete a method body in phpstorm, you need to alt+shift+{ or something weird (I don't recall). However, for vim it's di{ - delete inside {. This works with anything that has a matching symbol: ', ", (, [, you get my point.

In any intellij editor, how would you "delete everything inside the quotation marks"? With vim it's di". I can also delete from my cursor position until the next quotation marks with dt" - is this even possible in intellij without doing something like ctrl/cmd+right arrow?

Delete the current line and the line below: dj. Delete the current line and 3 below: d3j. Delete the current line and 5 above: d5k. How can I do these in intellij without spamming "delete line" 5x or selecting all 5 lines and hitting delete or backspace?

The point here is that everything I mentioned here is done by learning fundamentals and composing them together, whereas, if the action I'm giving as an example exists in intellij, you have to memorize an entirely new shortcut for it. This issue is actually what kept me from switching to phpstorm from sublime. I was going to remap the shortcuts to sublime shortcuts, but then I'd have issues whenever people told me the default shortcut they were talking about. It became not worth it.

1

u/phantaso0s May 10 '19

That is true. At one point I was using a LOT of shortcuts, you can basically do everything in PHPStorm with them.

But here's the thing: the editor of PHPStorm itself is not optimized for keyboard only. In Vim, you have two modes: one for writing (insert mode), one for moving around (normal mode). When you are in the normal mode, you can move by words, reach a character on your line, moving by the number of line you want up and down, only with keystrokes. I know that you can use ctrl and such to move around in your editor in PHPStorm but, I can tell you, it's way less powerful than what Vim allow you to do.

There is this IdeaVim plugin in PHPStorm which can give you a good idea what I'm talking about. However, Vim has other big advantages to me: with PHPStorm you will never have the versatility of the Vim config, you won't be able to share your config easily via Git, and so on and so forth.

1

u/fatboyxpc May 11 '19

Vim has 4 modes ;)

As for a vim config, there's a .ideavimrc file you can use, I believe, but I'm not an IntelliJ user, this is the word of friends that use it.

1

u/[deleted] May 10 '19

Thanks for your atical, I will read it, and just to find if there are some tips I need.

10

u/SparePartsHere May 10 '19

Why would anyone willingly inflict this upon himself is beyond me.

I am not saying that they shouldn't, it's everyone's free choice - I just don't understand why, when there is PhpStorm.

8

u/MattBD May 10 '19

As a Vim user, that's how I feel about PHPStorm. Every time I've tried an IDE, PHPStorm included, it's made me want to set fire to it, it's so screamingly annoying. It's usually painfully slow to start up, and the UI is horribly over-burdened.

Especially since I discovered PHPActor, there really isn't anything I don't have in Neovim that I like from PHPStorm. I've got very good completion and refactoring tools, I can navigate around as well as in any IDE, and the FZF and Ripgrep based search I use these days is extremely fast and efficient.

2

u/[deleted] May 10 '19

me too, I use windows os, the Win 7 os, it is too old, and when run normal IDE, the os sometimes blocked. I like vim, it is very light and fast, I do not need to wait for response after pressing any key.

5

u/Firehed May 10 '19

Same feeling. I live in the terminal, and writing code anywhere else is painful to me. I just want to fill my screen with nothing but code, and that’s what I do. I’ve curated a list of plugins that make my life easier without adding stuff that gets in my way.

People will think I’m crazy, and I’ll think they’re crazy. At the end of the day though, I don’t care what tools they use. It’s not a religion.

3

u/AcousticDan May 10 '19

I just want to fill my screen with nothing but code,

you can do this with an IDE just FYI

-3

u/[deleted] May 10 '19

out-of-the-box? No, FYI

7

u/AcousticDan May 10 '19

I see you've never actually tried an IDE, definitely not PhpStorm, because in fact you can, out of the box.

Also, there's literally a key combo for distraction free mode. You'd know that if you pulled your head out of your pompous ass.

So, FYI. You're absolutely, 100% wrong.

-5

u/[deleted] May 10 '19

bullshit, a key combo means it's not out-of-the-box

low lives

5

u/AcousticDan May 10 '19

Wrong. Out of the box means the functionality is built in.

By your logic VIM literally does nothing out of the box.

-4

u/[deleted] May 10 '19

I define my own out-of-the-box definition.

Try your best to challenge this.

Vim does that by default. :)

1

u/AcousticDan May 10 '19

But you can't search out of the box, hell you can't even quit "out of the box"

No code completion out of the box. Vim doesn't even have a feature to let you type out-of-the-box

→ More replies (0)

0

u/2012-09-04 May 10 '19

Obviously, Not A Real Dev.

→ More replies (0)

3

u/Metrol May 10 '19

I tried going down this road a while back. Installed NeoVIM and put in place a bunch of plug ins. Some of these plugins, at that time at least, were not trivial to install. It's been a year or more since this effort, so I don't recall which ones gave me issues. Might come back and visit this all again before too long.

A bigger problem for me was not being able to find a good plug in for dealing with database issues. I end up writing some pretty involved SQL that I eventually put into my PHP code. PHPStorm has a great database console for doing just that. Heck, even Eclipse and Netbeans handles this pretty well. They can all fall back to JDBC support to me send my queries to many kinds of databases.

The other issue I had was the amount of stuff that you need to memorize to be truly proficient at VIM. I'm able to use VIM quite a bit for one off edits on a server for both code and configs. When using it as a primary tool, I had trouble justifying the time and mental space being devoted to it rather than the software I'm trying to develop. I realize that can be resolved over time, but I haven't found myself with that kind of time yet.

As much as I rely on PHPStorm for the many things it provides, there is still a desire for something a bit more streamlined. Maybe it's having to run on the JVM, or being unable to use it from a CLI. Whatever the case may be, I can fully appreciate the desire developers have to try and get something like VIM to work like an IDE.

I wish the folks putting this effort into VIM the best of luck with it!

1

u/[deleted] May 10 '19

can you list issue or feature you want, maybe we can discuss vie email. [email protected]

70

u/[deleted] May 10 '19

Been there, done that.

No.

1

u/[deleted] May 10 '19

Lol yeah it’s like using nano for those quick changes...

0

u/[deleted] May 10 '19

[deleted]

18

u/IntenseIntentInTents May 10 '19

PhpStorm just seems to "get" PHP more than any other editor I've used. I can ctrl-click something and there's a 99% chance it will find the source (or usages) even with stringly-typed services.

Throw in some phpdoc to help it and it's just a great experience.

...I swear I'm not a shill.

16

u/[deleted] May 10 '19

Thinking of using something different than PHPStorm makes me sick.

I can't tell how many ways this IDE is better than any other. It saved my ass with the history so many times that worth the price...

11

u/2012-09-04 May 10 '19 edited May 10 '19

PhpStorm's LocalHistory pays for its $100/year in saved otherwise-lost time usually within the first 2 months of me purchasing it. That alone is worth the subscription price, if you ask me.

I also lean on it heavily for code completion (not the idiotic vim variety), XDebug support, and git merge conflict resolution.

6

u/phantaso0s May 10 '19

It's what I thought. Except that the local history in Vim is even more powerful than the one from PHPStorm.

It basically save every undo you can do in a file. You can even search through them with mundo

1

u/postmodest May 10 '19

Does it save it after close tho?

2

u/[deleted] May 10 '19

yeah, the undo history is saved.

2

u/phantaso0s May 10 '19

Yes, it saves it per file. It's configurable, like everything in Vim.

It's a tree, too. Which means that if you undo your changes, then begin to do some changes again, it will create a new branch. You can go back to any branch you like.

This is really cool.

2

u/llbe May 10 '19

It's indeed very powerful. Personally I added this to my vimrc many years ago and :ClearUndo is stuck in my fingers now (I type it way too often and sometimes without noticing)

function! <SID>ForgetUndo()
    let old_undolevels = &undolevels
    set undolevels=-1
    exe "normal a \<BS>\<Esc>"
    let &undolevels = old_undolevels
    unlet old_undolevels
endfunction
command -nargs=0 ClearUndo call <SID>ForgetUndo()

Edit: I don't want to remove it, because I like it too - I like "committing" the changes by clearing undo time from time.

9

u/therealgaxbo May 10 '19

Of all of the features that PhpStorm has that are hard or impossible to replicate in vim, it's strange that both of you talk about local history, an equivalent of which has been part of a default vim installation for nearly a decade ¯_(ツ)_/¯

1

u/[deleted] May 13 '19

Everything you can nearly think off... PHPStorm has a key or button to do it. I've mention the history because it's the most noticeable feature that saves my ass off.

But, lets talk about others as well.

  • Changelists (Having a control of everything you've touched without pain)

  • Issue management (You can check in into your favorite Bug Tracker and join with your IDE and using changelists as a Issue tracking system)

  • Structure of a class. If you have long 4000 lines of code classes... you're gonna need this.

  • DocBlock inspection from any part of the code with CTRL-Q to get that doc info.

  • Vagrant support.

  • Inspections support for example PHPCS or whatever you've got it.

  • Synchronization with remote SFTP/FTP servers with DIFF.

  • Auto-completion with snipets.

  • Debugging.

  • GUI to manage TODO's

1

u/2012-09-04 May 10 '19

No way. It has its own internal git-like repo for every keystroke change that I can rollback to even if the file or entire directory is completely deleted?!?

3

u/MattBD May 10 '19

I didn't know about this myself, but there's an article about it at https://advancedweb.hu/2017/09/12/vim-using-undo-branches/ and it looks pretty comprehensive.

1

u/[deleted] May 10 '19

Other developers in the office use intellj (not phpstorm).

I am the only one who uses vim.

They don't use xdebug, neither do they need git merge conflict function.

Code completion yea, but it doesn't help when you don't get how the bugs play around.

-3

u/2012-09-04 May 10 '19

Not Real Developers.

21

u/pragmageek May 10 '19

The thing that would beat phpstorm, is phpstorm detangled from java.

3

u/[deleted] May 10 '19

have you used the proper PHPStorm standalone IDE? or are you talking about the PHPStorm plugin for Intellij?

1

u/pragmageek May 12 '19

Im talking about the standalone.

0

u/[deleted] May 10 '19

[deleted]

5

u/[deleted] May 10 '19

i mean if you're using the PHPStorm plugin for IntelliJ, you'll probably have a worse time than using the standalone PHPStorm IDE app. just from people on my team who use the plugin, they have issues more often than the standalone app

3

u/SurgioClemente May 10 '19

PhpStorm is more integrated. I used to use IntelliJ because I wrote Java and Ruby along side PHP and liked having the ability to quickly switch.

Now that I am 99% PHP, PhpStorm is a far better experience and it is more up to date than the plugin releases. If I still need to udpate some java or ruby I'll open IntelliJ separately.

2

u/erayaydin May 10 '19

You can with heavy configuration. But its will be PhpStorm again, its will just look like Vim 😅

2

u/fatboyxpc May 11 '19

And act like vim, which is quite an important distinction ;)

3

u/progzos May 10 '19

While I agree that Phpstorm has some cool features, I still use vim because I like to have some free RAM left.

Also, with the right plugins, you get very close to a full ide experience. But to each their own I guess :)

6

u/SurgioClemente May 10 '19

How much ram do you have that 500mb is causing issue...? My browsers use more ram than PhpStorm...

2

u/4mstephen May 10 '19

Coming from sublime text I noticed my habits of new Windows do not play nice with phpstorm and ram usage. Also can't help but notice Java houses a lot of that usage. 1.9GB of just the Java framework to run phpstorm.

3

u/SurgioClemente May 10 '19

Something must be wonky...

My PhpStorm 2019.1 with an empty PHP project uses 440MB. Switching to my old work project with 7000+ PHP files uses 657MB

1

u/4mstephen May 10 '19

Php storm only takes that much, but I suppose you're not thinking about Java, it is the only application I have that needs it. So in my instance an empty new PHP Storm takes ~500MB+1.9GB

1

u/SurgioClemente May 11 '19 edited May 11 '19

Are you using the bundled JRE? https://confluence.jetbrains.com/display/IDEADEV/JetBrains+Runtime+Environment

I'm not sure that matters actually the entire JRE should not be loaded into RAM. What do your processes look like?

PhpStorm is also my only java application

Here is my before PhpStorm: https://imgur.com/iYwji3y
And here is after PhpStorm has loaded that large PHP project I mentioned: https://imgur.com/I4nCmnA

I have it sorted by committed memory, you can see no enormous java run time hogging ram.

And here is my ubuntu machine loading and older (2015 or so) version intellij. This machine only has 2GB of ram total

Before: https://imgur.com/pnReSUX
After: https://imgur.com/dpRBXpi

1

u/4mstephen May 10 '19

Here: In a Java program, the memory footprint is predominantly made up of the runtime environment in the form of Java Virtual Machine (JVM) itself that is loaded indirectly when a Java application launches.

1

u/progzos May 13 '19

When doing extended analysis on code, it takes something like 3 Gb, and I used to have only 4 Gb....

7

u/laygo3 May 10 '19

I get that it's capable, but at some point you've gotta learn all that, figure out what works best, tinker tinker tinker. I'd rather invest that time in the application I'm building.

Don't get me wrong, I AM a tinkerer . . . but not with my livelihood.

0

u/progzos May 10 '19

But to me closed source software is not something I would spend one second with, so there's that.

8

u/AcousticDan May 10 '19 edited May 10 '19

I'm assuming you don't drive a modern car, never fly on an airplane, use any site other than reddit, etc...?

Edit: I have you tagged as "Teddy from Antitrust"

3

u/SurgioClemente May 10 '19

Nor own an iPhone or Android phone... let alone use any popular apps/games... only read on paperback

1

u/progzos May 13 '19

Exactly, I use a bicycle, travel by train, cook my own vegan food, use as much free software as I can and have a very old phone.

1

u/AcousticDan May 13 '19

travel by train

Steam engine?

1

u/progzos May 13 '19

No, Steam is proprietary software. We use a herd of GNUs.

-1

u/[deleted] May 10 '19

good to hear that

I know you use Facebook too

1

u/2012-09-04 May 10 '19

Ah the one true GPL copyleft hipster who's still left alive!

1

u/progzos May 13 '19

I hope one day you'll see the light my brother. May the Gods of free software be ever in your favor.

1

u/[deleted] May 11 '19

I'd still use something Sublime or Atom over VIM. The only time I'm dropping into a editor with the shell is when I am modifying config files or on a server, and even then its NANO, not VIM.

2

u/fatboyxpc May 11 '19

You can use vim with the native OS GUI (GVim), it doesn't have to be in a shell. That said, it makes a lot more sense to use vim than nano because you get "nano" if you stay in vim's insert mode, but nano doesn't have even half of vim's features.

1

u/TerribleBanana May 10 '19

If only uploading to ftp server wasn't broken. I'd love it. 8 years waiting for it to be fixed is a joke.

8

u/AcousticDan May 10 '19

who uploads their code via FTP these days? Honest question.

Why not put it in a repo, and then deploy on your server?

3

u/MattBD May 10 '19

Better yet, use Deployer. It's worth it for the symlink deploys alone.

2

u/[deleted] May 10 '19

my team, because some of them don't do it locally.

and because they want to modify the files in vendor/, don't ask me why.

3

u/[deleted] May 11 '19

Modifying packages in vendor? Not good. So you guys just never upgrade your vendors? Brutal.

1

u/[deleted] May 11 '19

We upgrade the vendor for sure. But every time after upgrading, we have to modify the same thing about for the same bug.

-2

u/2012-09-04 May 10 '19

Not Real Developers.

1

u/[deleted] May 10 '19

i'm with you, but i still have clients who want to control their own server (usually packaged with godaddy or something) and only provide me with a ftp login

1

u/[deleted] May 11 '19

gitftp in that case.

1

u/[deleted] May 11 '19

gitftp

very cool, thanks

1

u/TerribleBanana May 10 '19

I have a keyboard shortcut u which uploads the current open file to the project's remote server. Using. FTP or SFTP.

I do use Acrosync to rsync local to remote, but I like the control of simply uploading a single file with a single keypress combo, in a single app.

Trouble is, about 1 in 10 times, this will truncate the remote file to 0 bytes and hang Phpstorm while it does some kind of "collection" forcing me to kill Phpstorm.

1

u/yelow13 May 10 '19

It's broken? I use it every day (SFTP)

My only issue is that files aren't uploaded on git pull

0

u/[deleted] May 10 '19

[deleted]

1

u/TerribleBanana May 10 '19

It's a known issue, marked as major I think, on the jetbrains bug tracker. It gets stuck in the collection phase.

2

u/laygo3 May 10 '19

I'm using SFTP & I don't have any problems. Are we talking bulk upload or on save deployment?

If bulk, I've been using scp/rsync, worst case scenario filezilla.

0

u/[deleted] May 10 '19

[deleted]

1

u/Atulin May 10 '19

PHPStorm is one JetBrains IDEs. They're basically all identical. Chances are, that whatever language you're seeking - JetBrains has an IDE for it.

PHPStorm itself, though? Certainly. Javascript, HTML, CSS, most CSS preprocessors, Typescript, and some other sub-types of JS. Some HTML preprocessors too.

And if not, there's 90% chance there's a plugin for that. you can use your PHPStorm for Java, C#, Go, even Flutter and Kotlin if you so desire.

2

u/[deleted] May 10 '19

No love for vscode?

1

u/[deleted] May 10 '19

i donot use vscode. since I do not find anything that vscode can but Vim can not

1

u/Kaapaala May 10 '19

Nobody mentioned it afaik but does it support debugging and breakpoints? If not that's a hard no for me

2

u/[deleted] May 10 '19

of cause IT support. you can check out my video on YouTube. debug in spacevim

0

u/psihius May 10 '19

A text editor cannot be an IDE even if you install a 1000 and 1 plugin.

IDE is not just a text processor.

2

u/[deleted] May 10 '19

even if with lsp?

3

u/psihius May 10 '19

Does not matter - those have completely different design principles behind them.

2

u/[deleted] May 10 '19

all IDE feature is based on command line tools, if you are family with these command, you do not need IDE, you can run this command with neovim or vim8 's job api.

2

u/Tred27 May 10 '19

This is what people fail to understand, most of the IDE utils come from or have an equivalent command line tool that vim can plug into natively most of the time, if not it is valid to install a plugin that closes that gap - deoplete with a php source give me autocompletion similar to what an IDE has, ctags gives me navigation, phpcs on save for .php files gives me code styling, it's really simple tbh and learning vim for the modal editing alone is a huge boost in productivity and allows you to use the mouse less.

1

u/[deleted] May 10 '19

yeah, IDE hide the major logic of this command. but people should understand these command.

4

u/barbw1re May 10 '19

What do you think it has to provide which is not available/possible via plugins?

-11

u/2012-09-04 May 10 '19

Full XDebug support. You noobs will never understand how I can 10X your asses with legacy code.

4

u/Garethp May 10 '19

That's actually something that vim does have a pretty decent plugin for actually, right here

1

u/AxaliaN May 22 '19

I agree with you there.

8

u/Xanza May 10 '19

Vim is not an IDE. Vim is a text editor. If you're looking for IDE functionality, then use an IDE. Don't modify a text editor to do things something else already does well...

Maddening.

5

u/[deleted] May 10 '19

Oh God....

3

u/pvgt May 10 '19 edited Oct 31 '25

waiting vast merciful enter aback compare chief provide correct trees

This post was mass deleted and anonymized with Redact

5

u/Tred27 May 10 '19

That plugin is one of the best there is but it's nowhere near the full feature set of vim.

-12

u/hmiguel204 May 10 '19

Lol no, fuck vim

4

u/Xanza May 10 '19

I fell victim to the meme that Vim is hard to close!

Literally you.

-4

u/pikknz May 10 '19

Vim is just for micro edits at the command line, I use it quite often. Trying to fudge it into an IDE seems a waste of time.

7

u/Xanza May 10 '19

Vim is just for micro edits at the command line

What shit are you smoking? Seriously.

2

u/recycledheart May 10 '19

Its amazing how the weather changes over 20 years.. I stop viewing this sub for a couple years and I don't even know the place anymore. Its like stepping into a PhpStorm struggle session now. It used to be the Vim loonies, haha! Meanwhile I still ST2 and just pretend I don't care..

0

u/pikknz May 10 '19

Really? You should type war and peace in Vim?? Vim is okay if you are doing rapid development and changing files a little bit on the server before commiting the rough changes back to your git repository. I am smoking something? A weak weird argument by you and your loser compadres. Phpstorm is very nice and should be preferred to Vim in almost all regards.

2

u/Xanza May 10 '19

Vim is literally developed to type war and peace and not doing "rapid development and changing files a little bit."

You clearly not only don't understand what Vim is, but you clearly don't understand how to use it, either. Anyone who does wouldn't be making any of these claims which is why my "compadres" are downvoting you. Not because I said something they agree with, but because you said something they disagree with. Mainly that Vim is just for micro edits. It's an outrageously stupid statement.

1

u/[deleted] May 10 '19 edited Aug 17 '25

[removed] — view removed comment

2

u/[deleted] May 10 '19

no, spacevim is not normal vimrc, IT do not enable this language layer by default. if you use spacevim as php IDE, you can enable php layer. for Python user they can enable Python layer too.

1

u/Artaserse09 May 13 '19 edited Aug 17 '25

weather ripe quaint elderly intelligent quiet nine governor bear sharp

This post was mass deleted and anonymized with Redact

3

u/[deleted] May 10 '19

[removed] — view removed comment

1

u/Xanza May 10 '19

lol no. Vim is incredibly powerful and very easy to learn. But using Vim this way is just dumb.

2

u/Tred27 May 10 '19

I use vim 100% of the time and while I concur that vim is an awesomely powerful tool I can't say that it's been easy to learn, the learning curve was big and it took me a couple of months to become proficient at using it and I'm still learning about vim.

2

u/Xanza May 10 '19

To be able to open, close, edit, save, and move within a document takes vimtutor, so probably 10-15 minutes.

Maybe 2 days if your a slow learner. But I'll totally agree that mastering Vim is an uphill battle. I'm still barely proficient, sometimes.