WebStorm: Why doesn't Refactor work? - refactoring

I'm trying to do Refactor on WebStorm. I mark the function name I want to refactor, make a right click --> Refactor --> Rename, then the function name is surrounded in red frame, i.e.
and from this point I can change the name of the function. The problem is that the new name I give is not accepted by WebStorm and I can't just exit the mode of editing the name of the function and keep the new name.

Related

Change variable name in multiple lines in visual studio

So, I have some code for a Rect variable mageSection:
And I'd like to copy the same code for a different variable warriorSection. To achieve this:
So I'd like to know if there is a visual studio shortcut for allow you to change variable name in multiple line in visual studio without refactoring the whole variable name.i.e. I don't have to manually change those names from mageSection to warriorSectionfor these 4 lines.
It is a question about shortcut in visual studio rather than writing functions, as I'd like to know the shortcut for this. Many thanks!
Copy and paste the section of code.
Now select the pasted code and hit Ctrl-H to bring up the Quick Replace dialog.
In the top box, type "mageSection".
In the bottom box, type "warriorSection".
Hit Enter and it will find the first occurrence and replace it.
Hit Enter three more times...done.
If I'm understanding your question correctly you should be able to hold down alt while clicking into multiple lines and change them all at once. Then hit ESC to exit multiline editing.

Pycharm refactoring-renaming inside function

In Pycharm one can easily rename a variable project wide using the (shift + F6) key to refactor-rename a variable
But it is unable to do this inside a function.
A workaround would be to use search-replace, But as I've gotten used to refactor-renaming i would like to find a way to refactor-rename inside a function.
Thanks for reading
PyCharm recognizes the limited scope of the variable (inside the function) and refactoring behaves slightly different in this case - the usual refactoring dialogue no longer opens up.
The green background (in your example, the actual colour may differ depending on the color scheme and customisations) for all the variable's instances inside the function indicates pycharm is in this local refactoring mode. Just edit the variable name and you'll see all the variable instances being modified simultaneously. Press Enter when done and the green background disappears indicating that the local refactoring mode ended.

Emulate codePen twilight theme

I'm trying to make sublime text to look like codepen.io twilight theme. I was able to copy it besides for some categories. I don't know what the name of the scope is. Here's an image with the different words I want to change.
(The text from the image is JavaScript.)
I want to change the purple underlined words to purple, and yellow to yellow. What are the keywords (scope names) for the words?
The yellow underlined items in your example are class names (a special case of variable name in JavaScript (and most languages).
I don't believe a syntax scope exists in JS for class names. It seems they are scoped as simple variables. Assuming I am right you are going to need to define your own syntax scope, perhaps calling it 'className' or similar. The defining characteristic seems to be a leading Uppercase followed by a lowercase.
Then you'll need to reference that new name in the color scheme and make it yellow (#FFF000) http://htmlcolorcodes.com/.
The same goes for the purple where you might have a member or a property or anything accessible through dot notation (based on your example). Again I think you are going to need to add your own syntax definition to the syntactic definition file for the languages you want to use it in. The regex seems to be any alphanumerics following a dot (.) ending at the next dot found. The name might be 'dotValue' or similar. Then you'll need to add that new syntax to the color theme to make 'dotValue's purple (#9700FF).
Before you start doing any of the playing about required to get where you want to be by trial and error make very sure you have backups of the syntax and color themes in a known good state so you are able to get back to a safe state at any point you might go off the rails.
You can find the scope name for any part of a document in Sublime Text 3 by placing the cursor immediately to the left of it and then using Tools menu -> Developer -> Show Scope Name, which will pop up a little window showing the scope, along with a button to copy it to the clipboard. This functionality is also available through Ctrl+Alt+Shift+P.

how to come back when you are reading code in Xcode?

I have been developing in zend studio and there is a feature I miss a lot in Xcode. When you are reading code in a main function and you want to go in a specific function to read something, you can click in the left area of your current line of code were your are, and a flag-mark appears in that line of code, so you can go anywere else in the code and it will be very easy to come back to that line of code you were before because there is a flag and you only have to click on it and you automatically go back. Does Anybody know a similar way to do this in Xcode?
Unfortunately, this feature was present in earlier versions of Xcode (up to Xcode3 IIRC) and was called "Bookmarks", but it was removed since then.
You can use breakpoints (and disable them) as a workaround, even if it's not perfect. I personally prefer using other tricks, like "Open Quickly" and named tabs.
Alternate trick 1 : "Open Quickly"
One trick is to use Command+Shift+O (or "File" menu > "Open Quickly") to quickly open a file. In the field that appears, you can type:
The name or parts of the name of a file.
Typing "MainViewController" will propose to jump to the MainViewController.h or MainViewController.m file.
Typing "MainVC" will work too, as well as "MainViewCtrl", as long as the order of the letters you type is the same as the full name.
Very handy to just type "ContTVCell" to open the ContactsTableViewCell.h file that is hidden deep in subgroups of my project for example
Similarly, you may also type the name or parts of the name of a symbol, especially a method name.
For example, typing tvcellforrow will list you all the definitions of -tableView:cellForRowAtIndexPath: it could find in your project and let to jump to the one you want
When typing (parts of) the name of a file, adding : followed by a number at the end will allow you to directly jump at the corresponding line
For example, typing mvc:50 will propose you to jump to line 50 of MainViewController.h or MainViewController.m
Another trick : using (named) tabs
Don't forget that you can open tabs in Xcode, which can be very handy in this kind of situation.
When you are editing a file at some interesting position, you can create a new tab to browse elsewhere and go at any other place… and then go back to your first tab to find the code where you left it at the time you switched to the other tab.
Don't forget that you can name your tabs (simply double-click on their title) to give them a more explicit title. You may then quite think of them as "named bookmarks" somehow
Likewise, don't forget that you can detach tabs in separate windows too, if you prefer (for example to keep them around and visible on your secondary screen while you edit another part of your code)
You can even combine this with the "Open Quickly" trick presented above: once you made the "Open Quickly" field appear and typed something into it, instead of just validating using the enter key:
use Alt+Shift+enter to let Xcode present you a small widget that let you choose where you want the file to open (in the current tab, in another tab, in the assistant editor, in a dedicated window…)
use Alt+enter to open the file using the alternate navigation defined in Xcode preferences (Xcode > Preferences > Navigation > Optional Navigation). By default, the behavior when opening a file while using the Alt key is to open the file in the Assistant Editor. Personally I changed that in my Xcode preferences as I prefer to make Xcode open the file in a separate tab instead, which makes Alt+clic much more useful.
Sure, all those tricks with "Open Quickly…" and "Tabs" do not replace the bookmarks feature that you are missing. But they are still nice alternate ways to jump quickly to any position in your code, even any specific line of any specific file in your project, wherever you are in Xcode (even without having to have the Project Navigator visible on the left part of your window), and let you have multiple editors in different tabs to go quickly back to a part of interest in your code
its on top of your editor i have added two pics just check them.
When you navigate to another place in Xcode, say, open a different file, or Command-click and jump to definition, you can go forward and back by swiping right or left on the trackpad with two fingers.
You can also use keyboard shortcuts: Ctrl+⌘+→ to go forward, or Ctrl+⌘+← to go back.
Finally, you can click triangular buttons at the top left in your edit area.
There is a go back button at the top left of the editor!
If that is not good enough, whar I do is misuse breakpoints to set flags in my code. The breakpoint navigator thus becomes a table of flags. It isn't much but there you are.

add watch not working in Visual Studio 2010

I right-click in the Watch 1 window and select Add Watch but nothing happens.
It is very unintuitive. The command doesn't do anything beyond adding a new row and selecting it. You next type the name of the variable. More intuitive is right-clicking an identifier name in the editor window + Add Watch. Or drag + drop it into the Watch window.
Right click (in your code) on the variable or expression (select it) you want to watch. It will be added to the Watch window.
Little question, large answer! You give us few details of what is happening...
Summarizing, be sure that current statement is around the place where your desired watched variables are, so you can see them on debug mode, i.e.:
Place a break point near there (press F9). Remember that it must be where the variable exists (remember that on C/C++/C# a common variable created inside brackets ({ and }) will be inaccessible outside it - something like that occurs on other languages);
Run the program (F5) and do something that let you on the right place (like pressing a button that launches the function where there are variables you want to watch);
To choose a variable to watch, on debug you must press mouse right button on it and "add watch". "Walk towards" using debug functions step into (F11), step out (shift+F11), step over (F10) or run-until-next-break-point (F5).

Resources