How to, inside Visual Studio Code, to search for files with a certain extension containing a certain text - visual-studio-code

I know that it is possible to search files by their contents by clicking at the hourglass on the left side; I also know that it is possible to search for files by their name by using Ctrl+p or Ctrl+e.
The problem is: I need to do both. I need to, for example, search for some specific text, but only inside '*.ts' files.
Is there a way to do this inside Visual Studio Code?

There is a button under regex in global search: "Toggle Search Details" (ellipsis)

Related

VSCode split header files to the right automatically

When I click on a header file on the explorer, I want the header files to be on the right split of the editor automatically regardless of where I'm currently focused on the editor while the .cpp/.c files stay on the left side when I click on them.
Normally, when I click on a file on the explorer, regardless of the type of the file it opens it on the currently focused split. As someone who is used to working with 2 splits this can be really annoying on large projects.
How can I achieve this? Are there extensions for this? Or can I create something like a macro?

Cannot type upper case E in VS Code and Python [duplicate]

I would like to change the keyboard shortcut for quick fix in Visual Studio 2013, so that it matches the ReSharper equivalent (which I only use on my office machine). How can I do it?
One way to do it is to enter on the menu 'Tools', 'Customize' and click on the 'Keyboard...' button near the 'Close' button.
Inside this option you can search for the commands by name (I couldn't find the Quick Fix here), maybe you want the Edit.FormatDocument one, that makes the indentation for the documents automatically.
If you can't find this option, tell me your quick fix actual keyboard shortcut, so I'll be able to check which function it calls.
I did some research on the R# QuickFix option and maybe what you want is this is the option you want: View.ShowSmartTag.
Look at this doc: Identify and customize keyboard shortcuts in Visual Studio

Disable syntax highlighting for text files (*.txt) in vscode

When I open text files (".txt" plaintext files), in Visual Studio Code, they are syntax highlighted and also vscode starts offering suggestions as I type. How can I turn all this off and just use vscode as a simple editor for these files?
Here's how to fix it:
Open a text file.
In the lower right corner of the window, click the syntax highlighting language (in my case, C++):
A menu will appear at the top center of the window. Click Configure File Association for '.txt'...:
A list of languages will appear. Scroll down and choose Plain Text.
Now ".txt" files will be treated as plaintext and won't be highlighted, etc.

Visual Studio Code Search All Files

For example, get a php function named "example". How do I find out what other files I use this function for? I just want to search the files in the workspace.
Click the magnifying glass on the left side, put in the term, and press Enter / Return.
(Hit the little 3 dots to include/exclude files.)
Click the arrow to the left of the search box, and then you can do Search and Replace in files.
You can also find the functions specifically, as outlined here:
https://code.visualstudio.com/api/language-extensions/programmatic-language-features#find-all-references-to-a-symbol

Are there bookmarks in Visual Studio Code?

How can I set bookmarks in Visual Studio Code? I can't find any keyboard shortcuts.
Or is there anything else that I can use instead?
Yes, via extensions. Try Bookmarks extension on marketplace.visualstudio.com
Hit Ctrl+Shift+P and type the install extensions and press enter, then type Bookmark and press enter.
Next you may wish to customize what keys are used to make a bookmark and move to it. For that see this question.
You need to do this via an extension as of the version 1.8.1.
Go to View → Extensions. This will open Extensions Panel.
Type bookmark to list all related extensions.
Install
I personally like "Numbered Bookmarks" - it is pretty simple and powerful.
Go to the line you need to create a bookmark.
Click Ctrl + Shift + [some number]
Ex: Ctrl + Shift + 2
Now you can jump to this line from anywhere by pressing Ctrl + number
Ex: Ctrl + 2
Visual Studio Code currently does not support bookmarks natively. Please add this as feature request to our Git Hub issue list (https://github.com/Microsoft/vscode).
In the meantime there are some ways to navigate around the code based on your navigation history. You can Ctrl+Tab to quickly jump to previously opened files. You can also navigate within your code based on cursor positions using Goto | Back and Goto | Forward.
Both VS Code extensions can be used:
'Bookmarks'
'Numbered Bookmarks'
Personally, I'm suggesting:
Numbered Bookmarks, with 'navigate through all files' option:
ctrl + Shift + P in VS Code
In newly open field, type: Open User Settings
Paste this key/value: "numberedBookmarks.navigateThroughAllFiles": "allowDuplicates" (allow duplicates of bookmarks),
Or, paste this key/value: "numberedBookmarks.navigateThroughAllFiles": "replace"
NOTE
Either way, be careful with shortcuts (Ctrl+1, Ctrl+Shift+1,..) that are already assigned.
Personally, mine were in 2 conflicts, with:
VS Code shortcuts, that already exists,
Ditto clipboard (I've got paste on each call of bookmark)
The bookmarks extension mentioned in the accepted answer conflicts with toggling breakpoints via the margin.
You could do the same with breakpoints and select the debug tab on the left to see them listed. Better yet, use File, Preferences, Keyboard Shortcuts and set (Shift+)Ctrl+F9 to navigate between them, even across files:
If you are using vscodevim extension, then you can harness the power of vim keyboard moves. When you are on a line that you would like to bookmark, in normal mode, you can type:
m {a-z A-Z} for a possible 52 bookmarks within a file. Small letter alphabets are for bookmarks within a single file. Capital letters preserve their marks across files.
To navigate to a bookmark from within any file, you then need to hit ' {a-z A-Z}. I don't think these bookmarks stay across different VSCode sessions though.
More vim shortcuts here.
No extension
As an alternative you can do Ctrl + P as "Go to file" in your workspace and type:
partial name of your file and/or extension.
type # + any name of method, property, variable, class (symbol) etc.
in currently opened file navigate between symbols with #
I found it more convenient than Bookmarks extension. Of course it depends a lot on your naming conventions and how well you know your codebase.
Under the general heading of 'editors always forget to document getting out…' to toggle go to another line and press the combination ctrl+shift+'N' to erase the current bookmark do the same on marked line…