How to keep code foldings in PHPStorm/WebStorm like in TextMate? - folding

PHPStorm, unlike TextMate, "forgets" the folded code areas when closing and opening the file again.
Sometimes the foldings open by themselves after search-and-replace, even though there were no matches inside the folded areas.
Is there a way to make PHPStorm remember my foldings in PHP/JavaScript/CSS files?

This is currently not possible.
There's a bunch of related issues in our tracker
http://youtrack.jetbrains.net/issues/WI?q=%23Unresolved+folding

this can be possible by using comments like this
// <editor-fold desc="My Code009" defaultstate="collapsed">
// any code
//</editor-fold>

Related

Is it possible to make double space appear as tabs?

I'm working in a project that uses the standard javascript syntax. It's nice, but it uses spaces for indentation. Is there some way to make double spaces work as tabs, with the ability to set tab-space etc?
As far as I know, this is not possible. Spaces and tabs are different by nature and they're also used differently in different projects. Some projects prefer to maintain the standard of only spaces, or tab and spaces or only tabs.
What you're asking is basically: is it possible to show all letters A as a letter O?
However, something that might help for your case is automatic indentation / code beautifier. Most code editors have this feature and it basically indents your code based on a standard (which you most of the time can customize).
If you're using PHP Storm for example, the shortcut ctrl + alt + L will indent and beautify your code. On the ATOM editor you can install a package to add that feature.
Keep in mind that messing about with indentation might cause conflicts with git if you're part of a team. And, if you're part of a team it's always better to keep their standards anyway.
As a final note, spaces vs tabs is a religious war. Try to keep your team's or library standard is a good recommendation most of the time.

Textmate Hide/Show Comments

Is there any way with TextMate to hide comments when editing code? Sometimes I want to see my code with the full comments and other times just want to see the code itself with all comments hidden. I was hoping there would be a way to toggle the display of comments, but haven't been able to find anything about this.
It is something you will need to edit on a language by language basis, but it is very doable. Inside of Bundles -> Bundle Editor -> Edit Languages you will find the language definition that TextMate uses to highlight that particular syntax. Inside of the syntax definition you will find foldingStartMarker and foldingStopMarker.
You can add comment syntax to those to allow the folding off comments themselves. It might be pretty tricky for single line comments, but multiline comments, that have both a clear and unique start and stop syntax, should work fine.
For PHP, for example, we are going to want to add \/\* to the start syntax, and \*\/ to the end syntax. You will need to reload the bundle for these changes to take effect (or restart TM).

Cocoa: simple tabs

Does any one know how to create a tab bar like this:
I mean that simple tab, without rounded corners or texture, with "Untitled" string
Is this a standard control? Or is there an open source library for such tabs? I think I saw it in a open source editor or something but totally forgot which one.
There are no doubt other ways to do this, but one I've used often in the past is PSMTabBarControl. It's been around for a while, and forked a few times. The version at https://github.com/dorianj/PSMTabBarControl can be used with Xcode 4.
Documentation can be found http://www.positivespinmedia.com/dev/PSMTabBarControl.html.

Reformatting code in text mate to established code conventions - Visual studio's ctrl K+D equivalent on Text Mate

Can anyone tell me if there's a quick way to format your code in Text Mate, similar to pressing ctrl K+D in Visual studio?
Thanks!
Edit by Damien_The_Unbeliever:
For those not familiar with Ctrl K+D, it doesn't just indent code - it reformats it using the generally established formatting conventions in the editor - it may replace spaces with tabs or vice-versa for the indentation, ensure code is consistently indented, move braces to separate lines, etc.
TextMate reindenting and reformatting varies a little depending on the language you're using.
You can generally use the Text menu, that depending wether you have an active selection or not it will show you different commands under it. For example, if you have selected a section of code, there will be a Indent Selection menu item. If you have no active selection, it will be Indent Line.
To have this working properly, be sure to select the current language, if it isn't assigned yet (like on unsaved documents). If you're working with HTML, it will simply indent the lines depending on what's above it. It will keep line breaks intact.
If you need something to break out tags on new lines and properly format the document, you should use the Tidy command that is found in the Bundles menu, under HTML (or simply by using the shortcut CTRL+SHIFT+H. If you have a selection active at the moment that you use it, it will simply reindent that section. If instead you have no selection, it will properly reformat the whole document, including checking for tag validity and other errors.
The Bundles for other language have similar commands, like XML (still Tidy) and Javascript (that has a Reformat Document command).
As an ending note, I simply suggest to look into the Bundles menu; there are many little gems in it. ;)
Did you look in the menu bar? Under Text you have a couple of Reformat… entries that may fit your needs.
Beside these native features, some bundles — like the JavaScript one — have custom Reformat… commands : click on the little cog button at the bottom and explore your current language's bundle's content.

What is the most efficient way to cut/paste in Visual Studio?

I find that I am cutting and pasting a LOT when I program. For example, method, variable and class names are things I regularly cut/paste. I do use "ctrl+space" after typing part of a word to autocomplete them or popup intellisense when there's duplicates found.
But just for straight copy/pasting do you guys have any good shortcuts/tricks/tips to use?
I already use these shortcuts as I program but I wonder if I am missing anything?
ctrl+x (with nothing selected)
ctrl+v (with nothing selected)
ctrl+l (with nothing selected)
ctrl+shift+arrowKeys
If I could copy/paste quicker I think I'd be able to write code quite a bit faster.
In Visual Studio has multi-paste.
pressing Ctrl+Shift+V allows you to paste any of the 10 last things you cut/copied.
Install and learn ViEmu.
I have more of a hardware solution. On my MS 4000 keyboard I have the back and forward buttons right under the space bar bound to copy and paste respectively. This actually makes copying and pasting much easier than I thought it would when I first did it.
I use ClipX, which gives you system-wide multi-paste. You can paste any of the last [configurable number] of things in your clipboard. You can also save "favourite" items, which stick on the list forever.
Shift + Page Up/Down to select everything below/above the cursor.
If you're not using ctrl+shift+arrow to select whole words/lines, then that can help a lot.

Resources