Is there a way to save just one file in PhpStorm? - phpstorm

My traditional workflow must be a little different to the PHPStorm default. I often work on multiple files at the same time and want to be able to save just one file when I've finished with it, without saving the others that I've modified.
I've managed to turn off the auto-save feature. Now, when I edit files I get stars on the ones I've edited and they stay like that until I hit 'save'. So far so good.
But when press CTRL-S to save, expecting it to save the one file I'm looking at so I can go back to the ones with asterisks to polish them off too, it also saves ALL the other files too.
I hope there's some way to change this behaviour or set up something to allow me to save just one file at a time!

Yes, you can .. but that still does not change a lot (e.g if you change your settings, or run/re-run something -- all files will be saved automatically anyway). Eventually (after few weeks or month of adaptation) you will get used to this behaviour and quite likely will love it (yes, this means changing working habits a bit, which is quite hard to do (requires time) for some people/in some cases).
Anyway ... to enable "save single file" functionality:
Settings | Keymap
On that screen, in search box type "save"
The action you are after is called "Other | Save Document"
Assign whatever shortcut you want.
P.S.
This action will NOT ask for confirmation (same behaviour as standard save does).
P.P.S.
This action is available since PhpStorm v7 ONLY.

Related

Changing name of CSS every time the website code is updated in the server

We are using a product called "mouseflow" which basically does heatmaps and user recordings. The problem is, because we are updating the site a few times a day (due to bugs found, UI/UX changes etc), the recordings in the dashboard doesnt seen normal.
I would see something like this:
Here is the answer received from their support:
" It has to do with how we save the recorded pages on our end. We save the HTML shown to the visitor, but not the external resources like stylesheets, images and script-files. Those are loaded directly from your webserver. And if these files suddenly become available, it can throw off the playback and heatmaps.
In your case it seems you've recently made some updates to your live page, changing the filename of one of your stylesheets. The saved HTML was referencing the file 'https://mywebsite.com/app.e28780aef0c5d0f9ed85.css', which is no longer available on your server. Instead, you are now using the file 'https://mywebsite.com/app.20d77e2240a25ae92457.css'.
I suspect the filename of this stylesheet is automatically updated whenever the content is changed."
The problem is
My tech team tells me that CSS file name always changes after its mimified and they really cant do anything about it. On the other hand, we really want to know what the user is actually seeing.
Is there any way around it? Can we have a stable file name even after mimifying the file?
Another option for you could be to copy the contents of the CSS files to a static file hosted on your server. The file should have a name that would never change (like mouseflow.css). Mouseflow could then insert a reference to that file, to load the needed CSS. This is something I know they can do quite easily.
You would need to manually update the static file, whenever major changes are made to the CSS on the livesite - but you wouldn't have to do it every time the file names changes.
Like Ouroborus just said, there is no such thing as "we cant do anything about it". It is bounded to the way you or the designer leader tell how things will work.
Update the css 10 times a day isnt that much, so you can still manually changing the name the file name. If the file is called in a several files, but each file call the file again (not using an general header), so you can start work on it.
You also can keep an backup of all those old versions in your webserver.
And last, but not least, you can stop minifying your files, and work with something like SASS or LESS. Is way more productive and you will avoid this kind of issue.
Hope it helps you, and sorry about my english.
Best regards.
The point of changing the file name is to invalidate the client cache. Every time your team makes changes, the filename changes, and the browser knows it needs to download it again. If the content hasn't changed between two visits, the file name will be the same, and the client browser will used a locally cached version of the file if it has any.
So changing the filename makes the site update for everyone right after changes are published.
One solution is to remove the hash from the filename, and set a short cache duration, but that's bad for performance and not good practice.

Disabling notifications in PHP Storm 9

I am using PHPStorm 9.
I have installed PHPCS to sniff my code. It is properly configured, up and running.
I am working on a very old project, which was implemented in plain PHP, and not using any code standard.
As a result, every time I open any of those files, I get a message at the top of the screen saying that I have too many errors (code style errors).
I have a couple of problems with that.
First, I already know how bad the code is, so I don't need PHP Storm to tell me that all the time.
Second. That message appears and disappears every time I edit the code. As a result, the window editor is constantly moving up and down, which I find specially annoying.
Also, at the top of the screen it is showing me the breadcrumbs, to tell me where I am. I appreciate the help, but I don't actually need it.
So the question is, how can I configure the IDE to disable those two messages? (read arrow and orange arrow in the attached image).
Please notice that I don't want to disable PHPCS. I only want to turn off those annoying messages.
I was unable to find it out by myself because I don't even know how those messages are called. Certainly not 'popups', nor 'status bar'
Best regards
Nicolas
Answering my own questions, thanks to the help of the PHPStorm Support team, Vladimir Luchansky (perhaps you need to create an account to see the thread):
To disable breadcrumbs: Go to File->Settings->Editor->General->Appearance, and untick the option Show HTML Breadcrumbs. Then restart the IDE
To disable the PHPCS messages without disabling PHPCS itself: Well, that option is not available in PHPStorm 9. It will be available for a future release. According to Vladimir, a developer is working on it. In order to make this request to go up in the future request list, the request needs to get as much 'votes' as possible. So, if you are interested in this feature to be ready ASAP, please vote up here.
Best,
Nicolas
I don't believe there's any mechanism for suppressing those phpcs: Too many messages per file alerts. As an alternative solution, you could give this work-around a try:
Clone your current inspection profile via Preferences > Editor > Inspections. Name the new one "Strict (with phpcs)". Then, choose your old inspection profile from the Profile: dropdown box (thus, reverting your project's default inspection profile to your old one). Rename it to "Weak (without phpcs)" and disable phpcs for that particular profile by unchecking the PHP > PHP Code Sniffer validation option.
From this point forward, phpcs inspections (and related alerts, like the one you're concerned about) won't come into play as you're editing your files. However, whenever you do want to inspect one of your files using PHP Code Sniffer, you can do so easily via Code > Inspect Code > Inspection Profile > Strict (with phpcs)
Hope this helps!

Prevent PhpStorm from automatically saving files on close

When I close a file in PhpStorm, it saves the file automatically.
How can I change it to ask me "Do you want do save the file before closing?"
Autosave settings are under File | Settings | General.
http://www.jetbrains.com/phpstorm/webhelp/saving-and-reverting-changes.html
While autosaving is handy for local, non-vital projects, this can be disastrous in a live project, where every change needs to be checked first.
Update: In recent versions, they have been moved to File | Settings | Appearance and Behavior | System Settings | Synchronization
There is no way to disable automatic save completely, but you can partially control this behavior:
Note that those are optional autosave triggers, and you cannot turn off autosave completely.
The answer below from #Owen is not correct, since there is no way to completely turn off automatic save in the IDE.
Automatic save is the core design feature, we believe that it's much more efficient and productive than manual save. There is no way to disable this behavior or enable any confirmations, quoting the FAQ (WebStorm is based on IntelliJ IDEA platform, so the same applies):
Because IntelliJ IDEA has the ability to change so many files
simultaneously in large refactoring actions, and change them without
ever opening them, single file saves don't make very much sense. In
recognition of this, IntelliJ IDEA reserves the right to save any
of your files literally whenever it wishes. It's actually quite nice
to never have to worry about your file's save statuses, once you get
used to it.
"What if I don't like some changes I made, and want to
roll them back?", I hear you say. Well, for that IntelliJ IDEA
includes this amazing feature called the Local History.
Every time it saves your files, IntelliJ IDEA actually saves a diff of
your file from it's previous state, and saves that as well. You can
see the entire edit history of your files (going back some
configurable number of days), see the changes you've made, and roll
back any change. It rules triumphantly, and more than makes up for the
temporary disorientation caused by lack of single-file save.
This feature has been in IntelliJ IDEA for a decade, and now even Apple has recognized that it's better than manual saving and implemented it in Mac OS Lion.
Just my two cents to a similar issue:
I had PhpStorm seemingly auto-save on every keypress, which was making my live reload go mad. Turns out, I had checked Recompile on changes under Settings -> Languages & Frameworks -> TypeScript.
Hope this can help someone.

Detecting what changed in an HTML Textfield

For a major school project I am implementing a real-time collaborative editor. For a little background, basically what this means is that two(or more) users can type into a document at the same time, and their changes are automatically propagated to one another (similar to Etherpad).
Now my problem is as follows:
I want to be able to detect what changes a user carried out onto an HTML textfield. They could:
Insert a character
Delete a character
Paste a string of characters
Cut a string of characters
I want to be able to detect which of these changes happened and then notify other clients similar to "insert character 'c' at position 2" etc.
Anyway I was hoping to get some advice on how I would go about implementing the detection of these changes?
My first attempt was to consider the carot position before and after a change occurred, but this failed miserably.
For my second attempt I was thinking about doing a diff on the entire contents of the textfields old and new value. Am I missing anything obvious with this solution? Is there something simpler?
It is a really hard work make this working today, for several reasons, but
maybe you will need to restrict only to some browsers. read: https://developer.mozilla.org/en/XUL/Attribute/oninput the alternative to "oninput" is listen to all input events (keyboard, mouse, dragdrop) I suggest to use "oninput"
html is not perfect... even html5. input and textareas supports only single-range
selections. you can solve this using designmode/contenteditable instead of
textareas/textfield
detecting offsets of what changed is a hard work: read
-- https://developer.mozilla.org/en/Document_Object_Model_%28DOM%29/window.getSelection
-- http://www.quirksmode.org/dom/range_intro.html -- http://msdn.microsoft.com/en-us/library/ms535869%28v=VS.85%29.aspx -- http://msdn.microsoft.com/en-us/library/ms535872%28v=VS.85%29.aspx
you may need a "diff" algorithm written in javascript! http://ejohn.org/projects/javascript-diff-algorithm/
one personal note: detecting words, characters changes may be totally non-sense and not useful, detect instead paragraphs changes, or in case of an excel-like worksheet, the single cell
I hope this helps
feel free to correct my English!
My pseudocode/written out response would be (if I understand your question exactly) to use jQuery to detect keyup events and then save the input to the server via ajax, then also take the response and post it back to the input. This isn't very efficient, but basically the idea is that you're constantly posting and checking what else has been posted. If you want to see what someone else is doing in real time, you can ping the server every second or so and update with the response.
All of this of course can be optimized, but it still is kind of taxing for a server. You could also see if you can implement Google Topeka Wave for your project, or get in touch with Google Topeka to see how they do it :)

Viewing Word Docs READ ONLY

I have a report reading records out of a DMS system and I thought it would be nice to have a link to the documents that it is listing so that the users could view the actual documents.
However when it displays a Word doc it allows you to make changes and then save them, which rather undermines the DMS system.
I don't think there is a parameter (/r) in Word that does this so do any of you clever people out there have a solution please?
Here is a link to the command line switches in Word 2007. There does not appear to be such an option as you describe. The /r switch re-registers Word in the registry and closes. Probably the best way to do this is download the Word Viewer and use it to open the document rather than Word itself.
If you have the option to write a small web component, write a component that takes an ID and streams out the document, then link to that service from the report. The web server will make a local copy of the document for reading.
Of course, then users will be frustrated that their changes are going into a black hole, but it sounds like that may be a better problem to have.
There's a better answer for those using Sharepoint