Renaming a variable can affect many other files - intellij-idea

Just something I'm curious about. Here's what I do:
I have a class with a member(type) who I want to rename to alertType, for example.
I right click the member, Refactor->Rename.. and enter the new name.
I'm prompted if I want to rename getters and setter too, I say yes.
IntelliJ scans my whole project and gives me the list of changes
The default refactoring is so broad, it renames any variable called type, or many html tags.
I know I can exclude/remove these refactorings, but if I forget to do that, it breaks my codebase and I have to revert, which is a bit tedious.
My question is, is there a way to change the default rename behaviour to only include the Field to be renamed and References in code to parameter, method refactorings? I don't think I would ever want the dynamic and comment/string replacements- I'm just trying to quickly rename a single variable.

On the field you want rename, press ShiftF6 and the inline rename refactoring will start. Now press ShiftF6 again, and the rename refactoring dialog will appear. Here you have 2 checkbox settings:
search in comments and strings and search for text occurrences, disable those and it should fix your problem.

Related

Hide\remove language from VB.Net form list

Is there a way to make the language property list shorter? Make it show only EN-US and PT-BR, for instance, so it's easier to find them?
You probably don't need to do it.. You can likely just make your life easier like:
Make a new form, lets say it's called LocalForm.vb
Drop a label on it, lets say called HelloLabel
Set form to de-DE, set the text of the label to Hallo
Set form to fr-FR, set the text of the label to Salut
Set the form back to (default) - you now have LocalForm.resx, LocalForm.de-DE.resx and LocalForm.fr-FR.resx and you can add controls
Add a Button, called StartButton
Double click the LocalForm.de-DE.resx file
Dismiss the "if you mess this up you'll have to fix it yourself" dialog
Add a line for StartButton.Text Starten
Repeat for other language files
Dropping a control named XyzButton on the form, and then visiting each LocalFor.*.resx in turn and adding the locale for it is a lot easier than back-and-forthing with the language setting, though I know why it's done the way MS chose to do it - you're supposed to lay your form out perfectly with all its hundreds of controls, and then switch to French and write all the French for all hundreds controls, and then switch to German and write it all in German.. In a use case like that there isn't a lot of work to do with that awkwardly huge Language dropdown. Incremental adds that way are a bit of a pain..
Perhaps raise a connect bug/feature asking them to put the "already used" languages (as determined by the presence of Form.*.resx files) at the top of the list, and wait many years for it to be implemented :)
Note: There's a bit of a nuisance with this "edit the resx" in that if you rename a control it doesn't always get picked up. Last time I was localizing I threw together an app that watched (FileSystemWatcher) files named *Form.resx and if it saw a change (load the current version, compare to the prev version) that was a rename, it made the same change in the other files (or maybe alerted if they weren't in sync.. can't quite remember now and I've no idea where the code has gone)
Maybe don't rename your controls after you first decide a sensible name for them/add them to the translated resx..

How to move cursor to Vue methods, computeds, data quickly in VS Code?

I already tried using the symbol explorer in VSCode (CTRL+P then write #). It allows me to jump to data (because it's a method) but it won't jump to normal properties like "computed:" or "methods:"?
This would be useful when eg. I look at my component and think "Aha! I need to add a computed, so let's jump to computeds". I could just CTRL+F but this sometimes doesn't work if another variable or comment has 'computed' in its name
Currently, you can
use Ctrl+R to open Go To Symbol in Editor,
then enter some words like data, computed or methods and etc.,
then press Enter
The cursor would be moved to the selected symbol. Tested in Win10/v1.48.2
The easiest way how to do that is probably using Bookmarks extension.
I am using them and also I haven't find a better way how to solve same problem as you have.

Problem with intellij idea rename variable?

When I try to rename a variable using Shift + F6 or simply Refactor => Rename, sometimes intellij renames not only the one I want to, but also some other variables (in other files) with the same name and all their references which are completely irrelevant.
When I further studied that behavior I got to know that it happens only for public variables. Refer below screenshot. I tried to rename the squared variable (keywords). There are lots of totally irrelevant code lines are suggested below to rename accordingly.
Do some one know what the exact problem here? And a convenient solution?
Thank You.
Disable the option to search in comments and strings in the Rename dialog:
The option is available when you press Shift+F6 twice.

Accidental use of built in function as variable name?

I have been writing some VBA code to produce charts automatically, and at one point named a variable "CHARTTITLE" not realizing that this is a member of the Chart object. I have deleted this variable upon realizing my mistake. However, since doing so, wherever I employ something like
Charts(1).ChartTitle.Text =
It will automatically auto-capitalize to
Charts(1).CHARTTITLE.Text
I have tried search and replace over the entire project from .CHARTTITLE to .ChartTitle to no avail. I have also tried employing Option Explicit also without effect. I am worried that there is now some sort of memory issue or that I've overwritten something important. Is there any way to reset this back to its default state?
It's a benign effect and it's a long-standing bug relating to the way that VBA stores itself internally. A couple of things to try:
Change the first occurrence of CHARTTITLE in the module, or if in multiple modules in the first module that appears in the project explorer.
Export the module, remove it from the project, edit it using your favourite text editor and reimport it.

How to copy a word document section-by-section

I have to update a word document to the most recent company template but that task is not so easy as it looks.
According to this site all it takes is to perform the described steps but after doing it the document remained as it was before, for instance, the footer and header remained the same, that is, they were not updated to the ones set in the new template.
After spending some time on how to accomplish that task I realized that both the header and footer are not related to the template but to the underlying section instead.
Then, I took another approach that boiled down to copy only the section content without the header and the footer to the already defined sections in the new template and apparently it gets the job done.
Therefore, I would like to know if there is any way to perform these section copying automatically - through VBA - or even other better approach I can take ?
Personally, I wouldn't use VBA unless the task was huge. By the time you've created some code, run it, failed, re-written it, you'll probably find that it could have been completed faster manually, especially if, as appears, this is a one-off job. Of course, if you encounter a task which you realise is repetitive and time-consuming, then you might make use of the Macro Recorder.
I obviously don't have the documents in front of me but:
Do a little planning. Work out how many sections there should be, and of what type (Next Page Section Break, etc.).
Use Draft View and Goto (Ctrl-G), Section to help discover them.
Scribble down an outline of what the final headers/ footers should contain.
If applicable, note down the Style names from both templates and work out which ones need to be replaced.
(I would) work on a copy of the new template and copy the content from the old one. This will copy the styles from the old template at the same time. This might be the wrong way round for you - you'll have to decide this. Try both and see which is easiest to work with.
You can use the Replace dialog (Ctrl-H) to swap one style for another.
Display the Styles Window as well (Ctrl-Alt-Shift-S).
From the Styles Window you can show the Style Manager. From here, and Import/Export, you can Delete, Rename and Copy Styles. Be careful about deleting styles as it is difficult to gauge what they will default to.
I would leave Headers and Footers until (second to) last and, when doing so, start at the beginning of the document and progress forward-only through the Sections, copying from the old template if necessary.
I would leave Bookmarks until the very end; by that time it should be easy to Insert them. If you have copied content from the old document then it should have carried the Bookmarks across as well, so it just a question of making sure that they are still in the right place.
Again, I don't have the templates in front of me, so I appreciate that some of this advice may not be relevant.
Hint: It might take a few attempts to get this right. If you get stuck at some point bear it mind that it might be better to start over - if it gets messy it is sometimes tricky to recover.