Pycharm refactoring-renaming inside function - refactoring

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.

Related

What color should i change to make powerlevel9k visible

I have following prompt
~/repos/go/src/github.com/xyz/xyz-project > <branch_changed_icon> GG-000
Whenever i make the code change in the directory, the last part which is <branch_changed_icon> GG-000 goes dark black or gray. Which is is not visible on my extended monitor (monitor is shitty). If i make the commit/add, this prompt turns to green which is perfectly visible.
I was looking at powerlevel9k.zsh-theme file but couldn't figure out what change i have to make so that i can make this last part more visible.
The VCS segment is a stateful one and has the state included in the variable name.
So you have to write your Variables for the VCS segment like this: POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='red' in your ~/.zshrc.
Have a look at the P9K wiki for further informations.
Note that these variables will change, once the development branch will be stable.
And in general, if your colors are very dark, you should consider installing a color scheme for your terminal. If you use iTerm2, you can choose one here. That affects all of your Terminal, not just single segments. A popular scheme is "Solarized Dark".

Xcode Rename Variables Across Multiple Files

Normally in Xcode, when you hover over a variable name, Xcode will underline it and place a triangle to the right of the variable name that you can click on and select "edit all in scope." This allows you to rename all instances of a variable at once. However, this doesn't seem to work if you are working across multiple files, for example, when writing a program that has a header file with the class specifications, the cpp with the implementation, and maybe a main that tests the class. This method of changing all variable names doesn't work in this situation, that I know of. It allows you to change all variable names of one page, but it doesn't change the same variable elsewhere. Is there a way around this? I tried the refactoring menu, but I guess refactoring isn't supported in non-Apple languages, like C++. I hoping that there is a better option for multi-page variable renaming, other than using search and replace. Any help would be greatly appreciated.

Change Color of Text Being Currently Used (Terminal - OSX)

For reference purposes: I am using a Macbook Pro Retina (2014) and all software is up to date as of the time I am posting this question. (Using OSX 10.10.2 Yosemite)
I have been struggling for the past few days as I attempted to customized the Terminal window. Everything was going fine... until I decided I only wanted to change the color for the text that you are currently typing (text input) which will then be executed.
I have no problems getting into my .bash_profile and adjusting anything. I simply cannot seem to grasp the color concept well enough such that it only does this one thing for me. Currently my .bash_profile looks like this:
export PS1="\n\n\njboned$ "
export PATH="/usr/local/mysql/bin:$PATH"
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
Any assistance would be greatly appreciated. As a sidenote: I understand the 8-bit snippets used to represent the individual colors, however it seems I cannot figure out how to use them to address only the text input only.
To do what you are asking, these steps would be needed:
at the end of the prompt, turn on the text color which you want to show
when you press return (to complete editing) turn the text-color off.
bash does not reset attributes while you edit, so the color "should" work — while editing. As you edit, bash is likely to use escape sequences which clear the current line (which may fill it with whatever background color you have selected).
The real problem is how to reset the colors when you press Enter. That does not appear to have a straightforward solution: I do not see a way to rebind the Enter key to add features—no distinction is made between levels of interpretation, and you may not find it possible to enhance the Enter key. The key binding feature in bash talks mainly to the readline library; leftovers are sent to bash. In a binding you may be able to do these things:
send the name of a macro to bash, or a full echo command which resets colors (since readline has no echo of its own, it seems)
the Enter key (i.e., ^M), and
to readline directly, the accept-line function
Alternatively, what you could do is bind another key, say control/L to do the bash accept-line function as well as resetting color. Here are a couple of links which you would find useful to investigate how to do this:
how to bind the 'Enter key'
Complex keybinding in bash
In bash, how do I bind a function key to a command?
Smart preparsing with the bash shell

Is there any way to debug compiled components using Matlab Debugger?

Is there a way in which I can debug my compiled Matlab components, using native Matlab debugger, like Visual Studio "Attach to process" option, or something like that?
I mean EXE stand-alone files, DLLs, COM in-process servers or .NET components.
You can't debug them in the sense of being able to step through the MATLAB code line by line, as you can with MATLAB's own debugger prior to compilation. One of the steps that the MATLAB deployment products take is to encrypt the MATLAB code (so you can preserve your IP when distributing the deployed component). The ability to step through the code in a debugger after deployment would defeat the purpose of that.
I experimented with using something like :
try
catch ME
waitbar(0,ME.message)
end
This was quite an effective and generic solution.
you may want to break down the code into multiple parts and debug each to save compiling time.
good luck,
dan
You can follow the instructions to debug:
Debugging:
Using the Debugging Tool will let you stop your program in mid-execution to examine the contents of variables and other things which can help you find mistakes in your program. M-file programs are stopped at "breakpoints". To create a breakpoint, simply press F12 and a red dot will appear next to the line where your cursor is. You can also click on the dash next to the line number on the left side of the M-file window to achieve the same result.
Then press F5 or Debug->Run from the menu to run the program. It will stop at the breakpoint with a green arrow next to it. You can then examine the contents of variables in the workspace, step, continue or stop your program using the Debug menu. To examine contents of a variable, simply type its name into the workspace, but be warned: you can only look at the values of variables in the file you stop in, so this means that you'll probably need multiple breakpoints to find the source of your problem. There are several different ways you can move through the program from a breakpoint. One way is to go through the whole program, line by line, entering every function that is called. This is effective if you don't know where the problem is. There's also a way to simply step through the function you're currently stopped in, one line at a time, and instead of going through the child functions line by line MATLAB will simply give you the results of those functions.
Finally, note that you cannot set a breakpoint until you save the M-file. If you change something, you must save before the breakpoint "notices" your changes. This situation is depicted in MATLAB by changing the dots from red to gray. Sometimes, you'll save but the dots will still be gray; this occurs when you have more than one breakpoint in multiple files. To get around this (which is really annoying), you have to keep going to "exit debug mode" until it turns gray. Once you're completely out of debug mode, your file will save and you'll be ready to start another round of debugging. Using comments to help you debug code. you want to test the effects of leaving out certain lines of code (to see, for example, if the program still returns Inf if you take them out), you can comment out the code. To do this, highlight it and then go to:
Text -> Comment
Or press CTRL+R. This will simply put a '%' in front of every line; if the line is already commented out it will put another '%' there so when you uncomment them the pattern of comment lines will not change. Commented lines will be ignored by the compiler, so the effect will be that the program is run without them.
To uncomment a line go to
Text -> Uncomment
Or press CTRL+T.
Another use of commenting is to test the difference between two different possible sets of code to do something (for example, you may want to test the effect of using ODE113 as opposed to ODE45 to solve a differential equation, so you'd have one line calling each). You can test the difference by commenting one out and running the program, then uncommenting that one and commenting the other one out, and calling the program again.
How to escape infinite loops?
MATLAB can't directly tell you you have an infinite loop, it does attempt to give you some hints. The first comes when you terminate the program. Terminate it by pressing CTRL+C and MATLAB will give you a message telling you exactly what line you stopped on. If your program is running a long time, it is likely the line you stopped in is in the middle of an infinite loop. sometimes MATLAB won't even let you return to the main window to press CTRL-C. In this case you probably have to kill the whole MATLAB process. After this, add a "pause (0.001)" or a similarly small value in the loop you suspect to be the infinite one. Whenever MATLAB passes this instruction you will be able to interact with MATLAB for a (very) short time, e.g. go to the main window and press CTRL-C with MATLAB being able to respond to your command.

VS2010 Debugging: Display Datatip w/o mouseover (use keyboard)?

I'm in VS2010, on a breakpoint. How can I cause a datatip to be displayed for a given variable/expression w/o using my mouse to hover it?
That can't be done, exactly, but you can get the same result by selecting the variable you want to watch (using ReSharper's Ctrl + Alt + →/← can speed this up), and pressing Shift + F9, which will raise "QuickWatch" modal window with the datatip contained within.
If you prefer, you can also go into Options->Keyboard and bind the Debug.AddWatch to a different keyboard shortcut, and use that instead of Shift + F9, and then your variable data will persist in the Watch window so you can come back to it later (as suggested here)
You can also do this by opening the command window (Ctrl + Alt + A) and typing Debug.AddWatch variable_name.
While you can pin multiple windows in VS it will be a somewhat cumbersome experience and you will have to over it.
I personally use visual studio plugin called Oz Code, that automatically annotates all the local variables and intermediate results so I don't have to chose which variables to pinpoint.
The results looks something like this:
Will adding a watch not be suitable? When you hit your breakpoint the relevant details of the variable will be shown in the watch window.
Perhaps I have misunderstood what you're trying to achieve here!
You can click the 'pin' icon to force any datatip to stay open, and it will update to the current contents when you hit the breakpoint.
I don't know of a way to open a specified tip without pinning it, however.
The Locals and Autos windows might be helpful as they show all local variables, (they even show the return value of called functions!).
Note however that they show directly only variables in scope, so if you need a detail property that it is not yet menotioned in the code you can drilldown using the →/← keys, however if it is already mentioned in the code in the current scope then you should be able to see it directly in the Autos window.

Resources