I often find myself needing to check where a file is used in my node project (which other file imports it). What I'm doing now is right clicking on the editor showing my file, copying the file path, then doing a grep on my whole project using the filename. In this manner I'm able to 'walk up' the dependency tree.
However, I'm wondering if it'd be possible to make a shortcut for this sort of thing. Does anybody know if that's viable?
Include your node project root directory to a sublime project with Project / Add Folder To Project...
Right-click on the project directory in the sidebar, then select "Find in Folder..." from the context menu.
Enable Regular expression
Find: import.*filename
click on Find
filename must be replaced with the actual name. The search pattern can be further refined to match module names from 'filenames', for example. You will end up with a search buffer that lets you jump to each file for that a match has been found.
Maybe Find In Files , Activate with ctrl + shift + F
Related
I save several projects in a same folder by manual click Project -> Save Project As...
and I used to use cmd + ctrl + p to open Switch Projectlist to switch between projects
and everything's works fine.
but today, I accidentally remove my Switch Project list in by click Project -> Open Recent -> Clear Items, so my Switch Project list is empty now...
I know I could add them back through reopen ALL my projects. due to the number of projects is pretty a lot, that will be kind of annoying to add them back one by one.
I wanna know if there's a smarter way to do that for me.
maybe import all my *.sublime-project files from folder or something.
thanks
Short of manually opening every project, I don't think there is any way to do something like this directly. There isn't a command or plugin endpoint that I'm aware of that lets you open a project by name or filename, so it's not possible to create a plugin to do the work, and Sublime doesn't have the ability to pre-load the list of packages directly either.
That said, it is possible to manually update the list of recent projects, but whether or not that is more or less work than opening all of the projects is something to consider.
If you use Preferences > Browse Packages from the menu or the command palette, a file browser will open on your Packages folder. From there go up one directory level and go inside of the Local folder, where you will find a Session.sublime_session file.
Sublime saves it's state into this file when you quit it, and uses it to restore state when you start it again. Here you will find all of the saved information, such as the windows and files that were open and so on.
Changing this file will change the data that Sublime loads, so you can modify the session file to set up the data that you want. You need to make sure that you modify the file while Sublime is not running or your changes will be ignored and clobbered away. Also it's a good idea to make a backup of the file before you start in case things go pear shaped.
Down near the bottom of the file you will find a top level key named workspaces, and inside of it a recent_workspaces key:
"workspaces":
{
"recent_workspaces":
[
"/home/tmartin/local/src/OverrideAudit/OverrideAudit.sublime-workspace",
]
}
This is where the list of recent projects is stored for use in the menu and the quick switch project command. Particular things to notice are that the entries are naming sublime-workspace files, and that the paths are absolute.
NOTE: On windows, the filenames stored in the session file are in a format like /C/Users/tmartin and not c:\users\tmartin; on that platform you need to make sure that you adjust the paths accordingly. As long as there is already at least one entry in the list when you look at the session file, you can easily see how to construct the paths that you need.
Despite the name of the commands and menu items, what you're actually switching between is different workspaces. Every sublime-project is associated with a sublime-workspace file, which acts as a dedicated sublime_session file for that particular project. This mapping is one-to-many in that you can have multiple workspaces for the same project file, allowing you to reference the same paths in multiple windows but have different window layouts.
While Sublime is not running you can edit this file to add in the full paths to all of your workspace files; when you start Sublime up the list will be populated (every sublime-workspace file knows what sublime-project it is associated with).
What remains is whether or not it's quick to come up with the list of files in a way that you can easily paste them into the session file.
I am new to Sublime, used to using Dreamweaver as my web editor. I have my project folder open in the Sublime Text 3 and I need to search all the files for a particular link https://test.com. From what I found on the web I need to hit Shift+Ctrl+F, enter my search string and then in Where: type the folder path I want to search. I have done that but the result set is empty even though I know the string I am searching for is there multiple times.
I tried entering the full path: W:\Web\App1 (where App1 is the folder I have opened as the project folder) as well as App1 but nothing gets returned. What am I doing wrong here?
Similar to Ctrl+Shift+F, you can right-click on the folder you want to search in, then choose 'Find in Folder'
In the bottom 'Find' box, make sure to have the 'Find options buttons' (on the left of the image) correctly set.
This is a very powerful option I use very often. Now I've tested in my SublimeText3 to look for an url like the one you provide and it works fine, as usual. With this setup:
Regular Expression: Off, Case Sensitive: Off, Whole Words: Off
...but this options are pretty straightforward and shouldn't affect your basic searches.
I usually work on larger projects with many files that would contain the search query. So I would open the files I want to modify and do a find/replace across all currently opened files. Can this be done in vs code?
The feature I'm looking for is implemented in Notepad++, but I'd prefer not to have to switch editors for this task.
For me somehow it works just by typing ./ in the files to exclude field.
The ability to search only in the open editors is in the Stable Build v1.55.
As you can see, the icon is at the end of the files to include input so you will have to have that showing (click the three dots ... just below the search options if files to include is not already showing).
"Search: target particular set of files #20530" located here: https://github.com/Microsoft/vscode/issues/20530
Is tracking a search "scope" such as "all open files".
Hit Ctrl + Shift + F and enable the icon at the end of the 'file to include' text field
I don't think there's a way to do this. You can make a feature request on github. I think an extension could do it though.
There is a checkbox for this in the "files to include" field since version 1.55 (march 2021).
The answer was already mentioned (and accepted above) indeed typing ./ in the files to exclude box of the search window will allow you to only search in open files.
However the response mentioned that he was unsure why this worked. VSCode allows you to exclude all files in a directory by writing the directory in the exclude box. The directory . is the directory where VSCode is opened ie the root directory. The filter ./ excludes all files in the VSCodes root directory so all files are excluded. However opened files ignore any exclude filter. So if you exclude all files only the opened files will be searched.
The best way to find something you are searching for within a specific file in vs code would be:
Ctrl + p then pressing # on the search bar.
It will give you a list of all functions on the file, which makes it easier to track something down.
As an alternative to using Visual Studio Code itself, you can just search the file contents within the folder where unsaved files open in Visual Studio Code are located. This would be in one of these locations depending on which OS you are running:
Linux: /tmp/ (someone else running Linux can verify this)
macOS: ~/Library/Application\ Support/Code/Backups/
Windows: %APPDATA%\Code\User\
This extension is what I use for this purpose.
You may need to change the keybinding if there is a conflict.
Is there a way in sublime text where I can find a pattern and replace it with file names.
For example,
I have a bunch of file names that contain people.
I want to replace that with person.
in SideBarEnhancements there is an option to Mass Rename Selection... under Find Advanced to batch rename multiple files.
Menu: Find -> Find in Files...
Sublime is gonna open a new panel at the bottom, you just need to fill the fields. Inside the field Where, you can, for example, look up only for .txt files:
Find: People
Where: C:\Temp, *.txt
Replace: Person
No you cannot do a find and replace on a filename. Although there is a great package called SideBarEnhancements which would benefit from this feature. I will definitely submit a feature request.
Install the SideBarEnhancements plugin
Select the folder from side bar
Right click and open the context menu
From Find Advanced -> Mass Rename Selection... you can do this.
Has anybody tried browsing assembly language file (filename.s) in source insight?
I just added whole Linux kernel project into source insight but it does not support any of the assembly files.
When you create the project in Sourceinsight, it adds all the types of files (like *.c, *.h, *.cpp, etc) it knows. It also adds assembly files but only '.asm' and '.inc' files. To include all *.s files as assembly file in the project, You need to tell Sourceinsight to treat '.s' files as assembly files.
This can be by Document Options->Document Type -> select the x86 ASM Source File and then add on the in file filter box inside * s along with *.asm and *.inc. Once you are done with this, now you re-add all the files from root directory of the project (Project->add and remove files) and you will get the *.s files in Sourceinsight.
In The File field -> Load file -> Browse [give path]-> File Type [make it as all]
Then you will find your ".s" file open it ,
You can use it like normal files
in settings tab you should find it out.
There is an option to add support for all file types.
Method to unconditionally include all Files present in the directory (Folder) :
CREATE A NEW DOCUMENT TYPE :
Go to Options ==> Document Options ==> Document Type. Press 'Add Type' button. Create some new type called MY_Unconditional.
Set 'File Filter' for this type as, *, *.*. (* wild card indicates all the files. *.* indicates all the files all type of extension.)
Close the dialog box.
ADD ALL FILES TO PROJECT :
Go to Project ==> Add and Remove Project Files
Choose your directory
Uncheck the box, 'Show only known document types'. Now, it will show all the files in the directory.
Now, press 'Add All' button. press 'Add Tree' button also if required.