Как мгновенно изменить имя переменной для всех ссылок в проекте
Я работаю над некоторой игрой в VS10, и я хочу изменить имя какой-либо переменной, потому что я хочу расширить игру, но есть так много ссылок на нее, что я не знаю, с чего начать, Есть ли какая-нибудь горячая клавиша в VS10, которая сделает это мгновенно для меня? Я знаю, что есть горячая клавиша CTRL + H для NetBeans, но это не работает для VS10.
3 ответа
Во-первых, любая переменная всегда должна быть объявлена и использована в наименьшей области видимости.
В VS2010 всякий раз, когда вы переименовываете переменную, она подскажет вам, хотите ли вы, чтобы все ссылки на эту переменную были переименованы. Рядом с названием, где вы его изменили, появится небольшая красная полоса. Переместите указатель мыши на эту панель, и появится значок «Параметры для обновления ссылок на переименованный объект». Вы можете выбрать между переименованием сразу или с предварительным просмотром.
(Возможность переименования всех ссылок на переименованную переменную исчезает, когда вы идете и переименовываете другую переменную. Возможно, есть способ вернуться к более старым переименованиям, но я ее не нашел.)
Я попробовал переименовать общедоступное свойство класса. Автоматическое переименование работает также для ссылок на это общедоступное свойство, по крайней мере, когда оба находятся в одном файле кода.
Как сказал в своем комментарии Retired Ninja, вам в значительной степени нужны дополнения для Visual Studio (например, Visual Assist X).
Установка Visual Assist даст вам следующее меню:
. где кнопка «Найти ссылки» выполняет поиск всех ссылок на эту переменную/функцию/namespace/etc и заменяет ее (а не только обычный текстовый поиск).
Другой альтернативой является открытие окна «Найти и заменить» (нажмите Ctrl + F) и нажмите «Быстрая замена». Оттуда вы можете выполнять поиск и замену обычного текста (там также поддерживается подстановочные знаки и регулярные выражения (в разделе «Параметры поиска → Использовать:), если это помогает).
Как быстро переименовать переменные в VS C++
Допустим, у меня есть много переменных с названием «a», я хочу их все переименовать в «b» во время редактирования кода. Как можно это быстро сделать?
Переменная с именем old будет заменена на new_var (пример).
Edit -> Find and Replace -> Quick Replace
Дизайн сайта / логотип © 2023 Stack Exchange Inc; пользовательские материалы лицензированы в соответствии с CC BY-SA . rev 2023.3.11.43304
Нажимая «Принять все файлы cookie» вы соглашаетесь, что Stack Exchange может хранить файлы cookie на вашем устройстве и раскрывать информацию в соответствии с нашей Политикой в отношении файлов cookie.
Name already in use
visualstudio-docs / docs / ide / finding-and-replacing-text.md
- Go to file T
- Go to line L
- Copy path
- Copy permalink
- Open with Desktop
- View raw
- Copy raw contents Copy raw contents
Copy raw contents
Copy raw contents
Find and replace text
You can find and replace text in the Visual Studio editor by using Find and Replace (Ctrl+F or Ctrl+H) or Find/Replace in Files (Ctrl+Shift+F or Ctrl+Shift+H). You can also find and replace some instances of a pattern by using multi-caret selection.
[!NOTE] The content on this page applies to Visual Studio. If you’re looking for information that’s specific to Visual Studio Code—also known as VS Code—see the Find and Replace section of the Basic Editing page in the Visual Studio Code docs.
[!TIP] In Visual Studio, if you’re renaming code symbols such as variables and methods, it’s better to refactor them than to use find-and-replace. Refactoring is intelligent and understands scope, whereas find-and-replace blindly replaces all instances.
Find-and-replace functionality is available in the editor, in certain other text-based windows such as the Find Results windows, in designer windows such as the XAML designer and Windows Forms designer, and in tool windows.
You can scope searches to the current document, the current solution, or a custom set of folders. You can also specify a set of file name extensions for multi-file searches. Customize search syntax by using .NET regular expressions.
[!TIP] The Find/Command box is available as a toolbar control, but isn’t visible by default. To display the Find/Command box, select Add or Remove Buttons on the Standard toolbar, and then select Find.
Find and Replace control
- Press Ctrl+F as a shortcut to find a string in the current file.
- Press Ctrl+H as a shortcut to find and replace a string in the current file.
The Find and Replace control appears in the upper right corner of the code editor window. It immediately highlights every occurrence of the given search string in the current document. You can navigate from one occurrence to another by choosing the Find Next button or the Find Previous button on the search control.
. image type=»content» source=»media/vs-2022/find-and-replace-box.png» alt-text=»Screenshot of the Find and Replace dialog in the Editor in Visual Studio 2022.».
. image type=»content» source=»media/find-and-replace-box.png» alt-text=»Screenshot of the Find and Replace dialog in the Editor in Visual Studio 2019 and earlier versions.».
You can access replacement options by choosing the button next to the Find text box. To make one replacement at a time, choose the Replace Next button next to the Replace text box. To replace all matches, choose the Replace All button.
To change the highlight color for matches, choose the Tools menu, select Options, and then choose Environment, and select Fonts and Colors. In the Show settings for list, select Text Editor, and then in the Display items list, select Find Match Highlight.
Search tool windows
You can use the Find control in code or text windows, such as Output windows and Find Results windows, by selecting Edit > Find and Replace or pressing Ctrl+F.
A version of the Find control is also available in some tool windows. For example, you can filter the list of controls in the Toolbox window by entering text in the search box. Other tool windows that allow you to search their contents include Solution Explorer, the Properties window, and Team Explorer.
Find in Files and Replace in Files
- Press Ctrl+Shift+F as a shortcut to find a string in multiple files.
- Press Ctrl+Shift+H as a shortcut to find and replace a string in multiple files.
Find/Replace in Files works like the Find and Replace control, except that you can define a scope for your search. Not only can you search the current open file in the editor, but also all open documents, the entire solution, the current project, and selected folder sets. You can also search by file name extension. To access the Find/Replace in Files dialog box, select Find and Replace on the Edit menu (or press Ctrl+Shift+F).
. image type=»content» source=»media/vs-2022/find-files.png» alt-text=»Screenshot of the Find and Replace dialog box in Visual Studio 20222, with the Find in Files tab open.».
For more detailed information, see the Find in Files and Replace in Files pages.
. image type=»content» source=»media/find-files-vs2019.png» alt-text=»Screenshot of the Find and Replace dialog box in Visual Studio 2019, with the Find in Files tab open.».
For more detailed information, see the Find in Files and Replace in Files pages.
[!IMPORTANT] If you are using Visual Studio 2019 version 16.6 or earlier, the Find and Replace dialog box might not look like it appears here. Switch to the Visual Studio 2017 version of this page for descriptions that’ll match what you see on your screen.
When you choose Find All, a Find Results window opens and lists the matches for your search. Selecting a result in the list displays the associated file and highlights the match. If the file is not already open for editing, it is opened in a preview tab in the right side of the tab well. You can use the Find control to search through the Find Results list.
Create custom search folder sets
You can define a search scope by choosing the Choose Search Folders button (it looks like . ) next to the Look in box. In the Choose Search Folders dialog box, you can specify a set of folders to search, and you can save the specification so that you can reuse it later.
[!TIP] If you’ve mapped a remote machine’s drive to your local machine, you can specify folders to search on the remote machine.
Create custom component sets
You can define component sets as your search scope by choosing the Edit Custom Component Set button next to the Look in box. You can specify installed .NET or COM components, Visual Studio projects that are included in your solution, or any assembly or type library (.dll, .tlb, .olb, .exe, or .ocx). To search references, select the Look in references box.
[!NOTE] This section applies to Visual Studio on Windows. For Visual Studio for Mac, see Block selection.
Use multi-caret selection to make the same edit in two or more places at the same time. For example, you can insert the same text or modify existing text in multiple locations at the same time.
In Visual Studio 2022, we improved the multi-caret copy and paste experience. Previously, pasting multiple lines into multiple carets resulted in the entire clipboard being duplicated at each caret. Now, pasting multiple lines into the same number of carets will insert each line to a respective caret.
To use multi-caret, press Alt+Shift+mouse click or Alt+Shift+. and then use Ctrl+Shift+arrow key to expand selections. Next, press Ctrl+C to copy the text in multiple selections. Use Alt+Shift+mouse click to create multiple carets for each line to paste in where you want them. Finally, press Ctrl+V to paste each line at its own caret.
. image type=»content» source=»media/vs-2022/multi-caret-copy-paste.gif» alt-text=»An animation of the multi-caret selection action in Visual Studio.».
Additionally, you can use Alt+Shift+up arrow key (or down arrow key) or Alt+Shift+mouse drag to select with multiple carets. Previously, these gestures created a box selection. Now, a box selection transforms into multiple carets. This method is easier and faster than having to click in precise locations to insert individual carets.
[!TIP] If you prefer to keep using a box selection with Alt+Shift+arrow keys and Alt+Shift+mouse drag when you expand a multi-caret selection, go to Tools > Options > Text Editor > Advanced and select Use box selection.
The following keyboard shortcuts are for actions that are specific to multi-caret selection behaviors.
Shortcut | Action | Command |
---|---|---|
Alt+Shift+. | Use multi-caret | Edit.InsertNextMatchingCaret |
Ctrl+Shift+arrow key | Expand selections | Edit.SizeControlUp, Edit.SizeControlDown, Edit.SizeControlRight, Edit.SizeControlLeft |
Alt+Shift+up arrow key (or down arrow key) | Select multiple carets | Edit.LineUpExtendColumn, Edit.LineDownExtendColumn |
You can also access multi-caret selection from the menu bar by selecting Edit > Multiple Carets and then selecting the action you want.
. image type=»content» source=»media/vs-2022/edit-menu-multiple-carets-find-replace.png» alt-text=»Screenshot of the Multiple Carets fly-out menu in Visual Studio 2022.».
In the following screenshot, -0000 is selected in three locations; if the user presses Delete, all three selections are deleted:
To select multiple carets, click or make first text selection as usual, and then press Ctrl+Alt while you click or select text in each additional location. You can also automatically add matching text as additional selections, or select a box of text to edit identically on each line.
[!TIP] If you’ve selected Alt as the modifier key for mouse-click in «Go to Definition» from Tools > Options > Text Editor > General, multi-caret select is disabled. For more information, see Options dialog box: Text Editor /> General.
Use the following keys and actions for multi-caret selection behaviors:
Shortcut | Action |
---|---|
Ctrl+Alt + click | Add a secondary caret |
Ctrl+Alt + double-click | Add a secondary word selection |
Ctrl+Alt + click + drag | Add a secondary selection |
Shift+Alt+. | Add the next matching text as a selection |
Shift+Alt+; | Add all matching text as selections |
Shift+Alt+, | Remove last selected occurrence |
Shift+Alt+/ | Skip next matching occurrence |
Alt + click | Add a box selection |
Esc or click | Clear all selections |
Some of the commands are also available on the Edit menu, under Multiple Carets:
Русские Блоги
VS -код (Visual Studio Code) Замените все переменные в файлах PY одновременно
Как показано на рисунке, в файле PY я хочу изменить имя переменной
Шаг 1, сначала наведите курсор на переменной, которая должна быть изменена
Шаг 2, нажмите клавишу сочетания F2 (переименованный символ), всплывающее окно ввода
Если вы используете его в первый раз, вы запустите ошибку, следуйте приглашению, чтобы нажать «Да», установите пакет, а затем используйте его обычно
После установки последующая резюме операции:
- Мыши парят в имени переменной, которая должна быть изменена
- Нажмите F2 (переименованный символ)
- После входа в поле измените имя переменной, а затем вернитесь в автомобиль
- После завершения модификации!
Интеллектуальная рекомендация
Меч относится к предложению + 43: количество N сиша + Java
Оригинальное название: бросить кубики на землю, все точки кости сталкиваются с точкой точки кости. Введите n, напечатали вероятность всех возможных значений. (6 сторон каждой кости, точки от 1 до 6) Р.
Введение в Python 4
функция ввода Использование функции Функция input () является функцией ввода. Функция input () — это функция ввода. Когда вы пишете вопрос в скобках функции, функция input () будет отображать вопрос в.
Основные операции в R 01
Повторите основную операцию секретной книги ниндзя языка R учителя Се Иихуэй.
Мастерство, создание американской легенды очистки воды
Мастера — это не только технические специалисты и квалифицированные мастера, которые могут решить некоторые практические проблемы в производстве и жизни, но также авангарды, которые могут руководить п.
курсы памяти Лу Feifei (а, понимать память понимания мозга)
Понимание памяти, что память? Понимание памяти, что память? 1 Понимание мозга 2 Что такое память Функция 3 Память 3.1 общие воспоминания путь 3.2 Факторы, влияющие на память 4 запоминающий материал Че.