├── .editorconfig ├── .gitattributes ├── .github ├── CONTRIBUTING.md └── ISSUE_TEMPLATE.md ├── .gitignore ├── LICENSE ├── OpenInSublimeText.sln ├── README.md ├── appveyor.yml ├── art ├── context-menu.png ├── preferences.png └── settings │ ├── install-path.png │ └── open-solution-project-as-regular-files.png └── src ├── Commands └── OpenSublimeTextCommand.cs ├── Helpers ├── Logger.cs └── ProjectHelpers.cs ├── OpenInSublimeText.csproj ├── Properties └── AssemblyInfo.cs ├── Resources ├── Icon.png ├── Preview.png └── logo.png ├── Settings.cs ├── VSCommands.cs ├── VSCommands.vsct ├── VSPackage.cs ├── packages.config ├── source.extension.cs ├── source.extension.ico ├── source.extension.resx └── source.extension.vsixmanifest /.editorconfig: -------------------------------------------------------------------------------- 1 | # Top-most EditorConfig file 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | end_of_line = crlf 7 | indent_size = 4 8 | 9 | [*.json] 10 | indent_style = space 11 | indent_size = 2 -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /.github/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Looking to contribute something? **Here's how you can help.** 4 | 5 | Please take a moment to review this document in order to make the contribution 6 | process easy and effective for everyone involved. 7 | 8 | Following these guidelines helps to communicate that you respect the time of 9 | the developers managing and developing this open source project. In return, 10 | they should reciprocate that respect in addressing your issue or assessing 11 | patches and features. 12 | 13 | 14 | ## Using the issue tracker 15 | 16 | The issue tracker is the preferred channel for [bug reports](#bug-reports), 17 | [features requests](#feature-requests) and 18 | [submitting pull requests](#pull-requests), but please respect the 19 | following restrictions: 20 | 21 | * Please **do not** use the issue tracker for personal support requests. Stack 22 | Overflow is a better place to get help. 23 | 24 | * Please **do not** derail or troll issues. Keep the discussion on topic and 25 | respect the opinions of others. 26 | 27 | * Please **do not** open issues or pull requests which *belongs to* third party 28 | components. 29 | 30 | 31 | ## Bug reports 32 | 33 | A bug is a _demonstrable problem_ that is caused by the code in the repository. 34 | Good bug reports are extremely helpful, so thanks! 35 | 36 | Guidelines for bug reports: 37 | 38 | 1. **Use the GitHub issue search** — check if the issue has already been 39 | reported. 40 | 41 | 2. **Check if the issue has been fixed** — try to reproduce it using the 42 | latest `master` or development branch in the repository. 43 | 44 | 3. **Isolate the problem** — ideally create an 45 | [SSCCE](http://www.sscce.org/) and a live example. 46 | Uploading the project on cloud storage (OneDrive, DropBox, et el.) 47 | or creating a sample GitHub repository is also helpful. 48 | 49 | 50 | A good bug report shouldn't leave others needing to chase you up for more 51 | information. Please try to be as detailed as possible in your report. What is 52 | your environment? What steps will reproduce the issue? What browser(s) and OS 53 | experience the problem? Do other browsers show the bug differently? What 54 | would you expect to be the outcome? All these details will help people to fix 55 | any potential bugs. 56 | 57 | Example: 58 | 59 | > Short and descriptive example bug report title 60 | > 61 | > A summary of the issue and the Visual Studio, browser, OS environments 62 | > in which it occurs. If suitable, include the steps required to reproduce the bug. 63 | > 64 | > 1. This is the first step 65 | > 2. This is the second step 66 | > 3. Further steps, etc. 67 | > 68 | > `` - a link to the project/file uploaded on cloud storage or other publicly accessible medium. 69 | > 70 | > Any other information you want to share that is relevant to the issue being 71 | > reported. This might include the lines of code that you have identified as 72 | > causing the bug, and potential solutions (and your opinions on their 73 | > merits). 74 | 75 | 76 | ## Feature requests 77 | 78 | Feature requests are welcome. But take a moment to find out whether your idea 79 | fits with the scope and aims of the project. It's up to *you* to make a strong 80 | case to convince the project's developers of the merits of this feature. Please 81 | provide as much detail and context as possible. 82 | 83 | 84 | ## Pull requests 85 | 86 | Good pull requests, patches, improvements and new features are a fantastic 87 | help. They should remain focused in scope and avoid containing unrelated 88 | commits. 89 | 90 | **Please ask first** before embarking on any significant pull request (e.g. 91 | implementing features, refactoring code, porting to a different language), 92 | otherwise you risk spending a lot of time working on something that the 93 | project's developers might not want to merge into the project. 94 | 95 | Please adhere to the [coding guidelines](#code-guidelines) used throughout the 96 | project (indentation, accurate comments, etc.) and any other requirements 97 | (such as test coverage). 98 | 99 | Adhering to the following process is the best way to get your work 100 | included in the project: 101 | 102 | 1. [Fork](http://help.github.com/fork-a-repo/) the project, clone your fork, 103 | and configure the remotes: 104 | 105 | ```bash 106 | # Clone your fork of the repo into the current directory 107 | git clone https://github.com//.git 108 | # Navigate to the newly cloned directory 109 | cd 110 | # Assign the original repo to a remote called "upstream" 111 | git remote add upstream https://github.com/madskristensen/.git 112 | ``` 113 | 114 | 2. If you cloned a while ago, get the latest changes from upstream: 115 | 116 | ```bash 117 | git checkout master 118 | git pull upstream master 119 | ``` 120 | 121 | 3. Create a new topic branch (off the main project development branch) to 122 | contain your feature, change, or fix: 123 | 124 | ```bash 125 | git checkout -b 126 | ``` 127 | 128 | 4. Commit your changes in logical chunks. Please adhere to these [git commit 129 | message guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) 130 | or your code is unlikely be merged into the main project. Use Git's 131 | [interactive rebase](https://help.github.com/articles/interactive-rebase) 132 | feature to tidy up your commits before making them public. Also, prepend name of the feature 133 | to the commit message. For instance: "SCSS: Fixes compiler results for IFileListener.\nFixes `#123`" 134 | 135 | 5. Locally merge (or rebase) the upstream development branch into your topic branch: 136 | 137 | ```bash 138 | git pull [--rebase] upstream master 139 | ``` 140 | 141 | 6. Push your topic branch up to your fork: 142 | 143 | ```bash 144 | git push origin 145 | ``` 146 | 147 | 7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/) 148 | with a clear title and description against the `master` branch. 149 | 150 | 151 | ## Code guidelines 152 | 153 | - Always use proper indentation. 154 | - In Visual Studio under `Tools > Options > Text Editor > C# > Advanced`, make sure 155 | `Place 'System' directives first when sorting usings` option is enabled (checked). 156 | - Before committing, organize usings for each updated C# source file. Either you can 157 | right-click editor and select `Organize Usings > Remove and sort` OR use extension 158 | like [BatchFormat](http://visualstudiogallery.msdn.microsoft.com/a7f75c34-82b4-4357-9c66-c18e32b9393e). 159 | - Before committing, run Code Analysis in `Debug` configuration and follow the guidelines 160 | to fix CA issues. Code Analysis commits can be made separately. 161 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ### Installed product versions 2 | - Visual Studio: [example 2015 Professional] 3 | - This extension: [example 1.1.21] 4 | 5 | ### Description 6 | Replace this text with a short description 7 | 8 | ### Steps to recreate 9 | 1. Replace this 10 | 2. text with 11 | 3. the steps 12 | 4. to recreate 13 | 14 | ### Current behavior 15 | Explain what it's doing and why it's wrong 16 | 17 | ### Expected behavior 18 | Explain what it should be doing after it's fixed. -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | packages 2 | node_modules.7z 3 | template-report.xml 4 | 5 | # User files 6 | *.suo 7 | *.user 8 | *.sln.docstates 9 | .vs/ 10 | 11 | # Build results 12 | 13 | [Dd]ebug/ 14 | [Rr]elease/ 15 | x64/ 16 | [Bb]in/ 17 | [Oo]bj/ 18 | 19 | # MSTest test Results 20 | [Tt]est[Rr]esult*/ 21 | [Bb]uild[Ll]og.* 22 | 23 | # NCrunch 24 | *.ncrunchsolution 25 | *.ncrunchproject 26 | _NCrunch_WebCompiler -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2015 Mads Kristensen 2 | 3 | Licensed under the Apache License, Version 2.0 (the "License"); 4 | you may not use this file except in compliance with the License. 5 | You may obtain a copy of the License at 6 | 7 | http://www.apache.org/licenses/LICENSE-2.0 8 | 9 | Unless required by applicable law or agreed to in writing, software 10 | distributed under the License is distributed on an "AS IS" BASIS, 11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | See the License for the specific language governing permissions and 13 | limitations under the License. -------------------------------------------------------------------------------- /OpenInSublimeText.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.28125.3004 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenInSublimeText", "src\OpenInSublimeText.csproj", "{4B9DC4DD-B2D2-41E3-B33E-804F6F712049}" 7 | EndProject 8 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E8040FFF-3992-4875-93BE-720F36F5B5B4}" 9 | ProjectSection(SolutionItems) = preProject 10 | appveyor.yml = appveyor.yml 11 | README.md = README.md 12 | EndProjectSection 13 | EndProject 14 | Global 15 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 16 | Debug|Any CPU = Debug|Any CPU 17 | Release|Any CPU = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {4B9DC4DD-B2D2-41E3-B33E-804F6F712049}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {4B9DC4DD-B2D2-41E3-B33E-804F6F712049}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {4B9DC4DD-B2D2-41E3-B33E-804F6F712049}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {4B9DC4DD-B2D2-41E3-B33E-804F6F712049}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {9AE5EDD7-88C3-441F-8A2D-05CCCBFC317D} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Open in Sublime Text 2 | A Visual Studio extension that adds a menu command that 3 | lets you open any solution, project, folder or file in 4 | Sublime Text. 5 | 6 | [![Build status](https://ci.appveyor.com/api/projects/status/k8f8ny0jxq2h53wr?svg=true)](https://ci.appveyor.com/project/madskristensen/openinsublimetext) 7 | 8 | Download the extension at the 9 | [VS Gallery](https://visualstudiogallery.msdn.microsoft.com/384892a5-7b67-42f2-b7de-574ef254a02a) 10 | or get the 11 | [nightly build](http://vsixgallery.com/extension/2925bbf7-d48b-4abd-83dc-1cd711d9b9ba/) 12 | 13 | ------------------------------------ 14 | 15 | This extension is for those times where you have a project 16 | open in Visual Studio and you want to be able to quickly 17 | open it in Sublime Text. 18 | 19 | ## Prerequisite 20 | In order to use this extension, you must have Visual 21 | Studio 2015 as well as Sublime Text installed. 22 | 23 | You can 24 | [download Sublime Text](http://www.sublimetext.com/) 25 | for free. 26 | 27 | ## Solution Explorer 28 | You can open any solution, project, folder or file in 29 | Sublime Text by simply right-clicking it in Solution 30 | Explorer and select 31 | **Open in Sublime Text**. 32 | 33 | ![Context menu](art/context-menu.png) 34 | 35 | ## Settings 36 | 37 | ### Install Path 38 | The extension will automatically find **sublime_text.exe** 39 | when it's located at Sublime Text's default install 40 | directory. If it's installed at a custom location, you 41 | can easily change it in the settings: 42 | 43 | ![Install Path](art/settings/install-path.png) 44 | 45 | ### Opening Solution and Project files as regular files 46 | This will allow you the option of opening your solution 47 | and project files as regular files. By default, the 48 | extension will load the solution and project folders into Sublime. 49 | 50 | ![Open Solution and Project files as regular files](art/settings/open-solution-project-as-regular-files.png) 51 | 52 | ### Change Sublime's settings 53 | Sublime Text will by default remember which folders and 54 | files was open last time it was closed. That makes opening 55 | Sublime Text to a folder from the command line 56 | problematic (this extension uses same mechanism). 57 | 58 | ![Sublime Text Preferences](art/preferences.png) 59 | 60 | To turn off this behavior in Sublime Text, go to 61 | **Preferences -> User - Settings** and then add these two lines to the file: 62 | 63 | ```json 64 | "hot_exit": false, 65 | "remember_open_files": false 66 | ``` 67 | 68 | ## Contribute 69 | Check out the [contribution guidelines](.github/CONTRIBUTING.md) 70 | if you want to contribute to this project. 71 | 72 | For cloning and building this project yourself, make sure 73 | to install the 74 | [Extensibility Tools 2015](https://visualstudiogallery.msdn.microsoft.com/ab39a092-1343-46e2-b0f1-6a3f91155aa6) 75 | extension for Visual Studio which enables some features 76 | used by this project. 77 | 78 | ## License 79 | [Apache 2.0](LICENSE) -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | image: Visual Studio 2015 2 | 3 | install: 4 | - ps: (new-object Net.WebClient).DownloadString("https://raw.github.com/madskristensen/ExtensionScripts/master/AppVeyor/vsix.ps1") | iex 5 | 6 | before_build: 7 | - ps: Vsix-IncrementVsixVersion | Vsix-UpdateBuildVersion 8 | - ps: Vsix-TokenReplacement src\source.extension.cs 'Version = "([0-9\\.]+)"' 'Version = "{version}"' 9 | 10 | build_script: 11 | - nuget restore -Verbosity quiet 12 | - msbuild /p:configuration=Release /p:DeployExtension=false /p:ZipPackageCompressionLevel=normal /v:m 13 | 14 | after_test: 15 | - ps: Vsix-PushArtifacts | Vsix-PublishToGallery 16 | 17 | before_deploy: 18 | - ps: Vsix-CreateChocolatyPackage -packageId openinsublimetext 19 | 20 | deploy: 21 | - provider: Environment 22 | name: Chocolatey 23 | on: 24 | branch: master 25 | appveyor_repo_commit_message_extended: /\[release\]/ 26 | -------------------------------------------------------------------------------- /art/context-menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/OpenInSublimeText/fff61fec269dba3161143ae60e24dda094f08912/art/context-menu.png -------------------------------------------------------------------------------- /art/preferences.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/OpenInSublimeText/fff61fec269dba3161143ae60e24dda094f08912/art/preferences.png -------------------------------------------------------------------------------- /art/settings/install-path.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/OpenInSublimeText/fff61fec269dba3161143ae60e24dda094f08912/art/settings/install-path.png -------------------------------------------------------------------------------- /art/settings/open-solution-project-as-regular-files.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/OpenInSublimeText/fff61fec269dba3161143ae60e24dda094f08912/art/settings/open-solution-project-as-regular-files.png -------------------------------------------------------------------------------- /src/Commands/OpenSublimeTextCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel.Design; 3 | using System.IO; 4 | using EnvDTE; 5 | using EnvDTE80; 6 | using Microsoft.VisualStudio.Shell; 7 | 8 | namespace OpenInSublimeText 9 | { 10 | internal sealed class OpenSublimeTextCommand 11 | { 12 | private readonly Package _package; 13 | 14 | private OpenSublimeTextCommand(Package package) 15 | { 16 | _package = package; 17 | 18 | OleMenuCommandService commandService = ServiceProvider.GetService(typeof(IMenuCommandService)) as OleMenuCommandService; 19 | if (commandService != null) 20 | { 21 | var openFileMenuCommandID = new CommandID(PackageGuids.guidOpenInVsCmdSet, PackageIds.OpenInSublimeText); 22 | var openFileMenuItem = new MenuCommand(OpenPath, openFileMenuCommandID); 23 | commandService.AddCommand(openFileMenuItem); 24 | 25 | var openCurrentFileMenuCommandID = new CommandID(PackageGuids.guidOpenInVsCmdSet, PackageIds.OpenCurrentFileInSublimeText); 26 | var openCurrentFileMenuItem = new MenuCommand(OpenCurrentFile, openCurrentFileMenuCommandID); 27 | commandService.AddCommand(openCurrentFileMenuItem); 28 | } 29 | } 30 | 31 | public static OpenSublimeTextCommand Instance { get; private set; } 32 | 33 | private IServiceProvider ServiceProvider 34 | { 35 | get { return _package; } 36 | } 37 | 38 | public static void Initialize(Package package) 39 | { 40 | Instance = new OpenSublimeTextCommand(package); 41 | } 42 | 43 | private void OpenPath(object sender, EventArgs e) 44 | { 45 | var dte = (DTE2)ServiceProvider.GetService(typeof(DTE)); 46 | 47 | try 48 | { 49 | string path = ProjectHelpers.GetSelectedPath(dte, VSPackage.Settings.OpenSolutionProjectAsRegularFile); 50 | string exe = VSPackage.Settings.FolderPath; 51 | 52 | if (!string.IsNullOrEmpty(path) && !string.IsNullOrEmpty(exe)) 53 | { 54 | OpenSublimeText(exe, path); 55 | } 56 | else 57 | { 58 | System.Windows.Forms.MessageBox.Show("Couldn't resolve the folder"); 59 | } 60 | } 61 | catch (Exception ex) 62 | { 63 | Logger.Log(ex); 64 | } 65 | } 66 | 67 | private void OpenCurrentFile(object sender, EventArgs e) 68 | { 69 | var dte = (DTE2)ServiceProvider.GetService(typeof(DTE)); 70 | 71 | try 72 | { 73 | string path = $"\"{dte.ActiveDocument.FullName}\""; 74 | int line = 0; 75 | 76 | TextSelection selection = dte.ActiveDocument.Selection as TextSelection; 77 | if (selection != null) 78 | { 79 | line = selection.ActivePoint.Line; 80 | } 81 | 82 | string exe = VSPackage.Settings.FolderPath; 83 | 84 | if (!string.IsNullOrEmpty(path) && !string.IsNullOrEmpty(exe)) 85 | { 86 | OpenSublimeText(exe, path, line); 87 | } 88 | else 89 | { 90 | System.Windows.Forms.MessageBox.Show("Couldn't resolve the folder"); 91 | } 92 | } 93 | catch (Exception ex) 94 | { 95 | Logger.Log(ex); 96 | } 97 | } 98 | 99 | private static void OpenSublimeText(string exe, string path, int line = 0) 100 | { 101 | bool isDirectory = Directory.Exists(path); 102 | 103 | var start = new System.Diagnostics.ProcessStartInfo() 104 | { 105 | WorkingDirectory = path, 106 | FileName = $"\"{exe}\"", 107 | Arguments = isDirectory ? "." : $"{path}:{line}", 108 | CreateNoWindow = true, 109 | WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden 110 | }; 111 | 112 | using (System.Diagnostics.Process.Start(start)) 113 | { 114 | string evt = isDirectory ? "directory" : "file"; 115 | } 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /src/Helpers/Logger.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics.CodeAnalysis; 3 | using Microsoft.VisualStudio.Shell.Interop; 4 | 5 | public static class Logger 6 | { 7 | private static IVsOutputWindowPane pane; 8 | private static readonly object _syncRoot = new object(); 9 | private static IServiceProvider _provider; 10 | private static string _name; 11 | 12 | public static void Initialize(Microsoft.VisualStudio.Shell.Package provider, string name) 13 | { 14 | _provider = provider; 15 | _name = name; 16 | } 17 | 18 | [SuppressMessage("Microsoft.Usage", "CA1806:DoNotIgnoreMethodResults", MessageId = "Microsoft.VisualStudio.Shell.Interop.IVsOutputWindowPane.OutputString(System.String)")] 19 | public static void Log(string message) 20 | { 21 | if (string.IsNullOrEmpty(message)) 22 | return; 23 | 24 | try 25 | { 26 | if (EnsurePane()) 27 | { 28 | pane.OutputString(DateTime.Now.ToString() + ": " + message + Environment.NewLine); 29 | } 30 | } 31 | catch 32 | { 33 | // Do nothing 34 | } 35 | } 36 | 37 | public static void Log(Exception ex) 38 | { 39 | if (ex != null) 40 | { 41 | Log(ex.ToString()); 42 | } 43 | } 44 | 45 | private static bool EnsurePane() 46 | { 47 | if (pane == null) 48 | { 49 | Guid guid = Guid.NewGuid(); 50 | IVsOutputWindow output = (IVsOutputWindow)_provider.GetService(typeof(SVsOutputWindow)); 51 | output.CreatePane(ref guid, _name, 1, 1); 52 | output.GetPane(ref guid, out pane); 53 | } 54 | 55 | return pane != null; 56 | } 57 | } -------------------------------------------------------------------------------- /src/Helpers/ProjectHelpers.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using EnvDTE; 4 | using EnvDTE80; 5 | using System.Collections.Generic; 6 | 7 | namespace OpenInSublimeText 8 | { 9 | internal static class ProjectHelpers 10 | { 11 | public static string GetSelectedPath(DTE2 dte, bool openSolutionProjectAsRegularFile) 12 | { 13 | var items = (Array)dte.ToolWindows.SolutionExplorer.SelectedItems; 14 | var files = new List(); 15 | 16 | foreach (UIHierarchyItem selItem in items) 17 | { 18 | ProjectItem item = selItem.Object as ProjectItem; 19 | 20 | if (item != null) 21 | files.Add($"\"{ item.Properties.Item("FullPath").Value.ToString()}\""); 22 | 23 | Project proj = selItem.Object as Project; 24 | 25 | if (proj != null) 26 | return openSolutionProjectAsRegularFile ? proj.FullName : proj.GetRootFolder(); 27 | 28 | Solution sol = selItem.Object as Solution; 29 | 30 | if (sol != null) 31 | return openSolutionProjectAsRegularFile ? sol.FullName : Path.GetDirectoryName(sol.FileName); 32 | } 33 | 34 | return files.Count > 0 ? String.Join(" ", files) : null; 35 | } 36 | 37 | public static string GetRootFolder(this Project project) 38 | { 39 | if (string.IsNullOrEmpty(project.FullName)) 40 | return null; 41 | 42 | string fullPath; 43 | 44 | try 45 | { 46 | fullPath = project.Properties.Item("FullPath").Value as string; 47 | } 48 | catch (ArgumentException) 49 | { 50 | try 51 | { 52 | // MFC projects don't have FullPath, and there seems to be no way to query existence 53 | fullPath = project.Properties.Item("ProjectDirectory").Value as string; 54 | } 55 | catch (ArgumentException) 56 | { 57 | // Installer projects have a ProjectPath. 58 | fullPath = project.Properties.Item("ProjectPath").Value as string; 59 | } 60 | } 61 | 62 | if (string.IsNullOrEmpty(fullPath)) 63 | return File.Exists(project.FullName) ? Path.GetDirectoryName(project.FullName) : null; 64 | 65 | if (Directory.Exists(fullPath)) 66 | return fullPath; 67 | 68 | if (File.Exists(fullPath)) 69 | return Path.GetDirectoryName(fullPath); 70 | 71 | return null; 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/OpenInSublimeText.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | $(VisualStudioVersion) 6 | $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 7 | true 8 | Program 9 | $(DevEnvDir)\devenv.exe 10 | /rootsuffix Exp 11 | publish\ 12 | true 13 | Disk 14 | false 15 | Foreground 16 | 7 17 | Days 18 | false 19 | false 20 | true 21 | 0 22 | 1.0.0.%2a 23 | false 24 | false 25 | true 26 | 27 | 28 | v3 29 | 30 | 31 | 32 | Debug 33 | AnyCPU 34 | 2.0 35 | {82b43b9b-a64c-4715-b499-d71e9ca2bd60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 36 | {4B9DC4DD-B2D2-41E3-B33E-804F6F712049} 37 | Library 38 | Properties 39 | OpenInSublimeText 40 | OpenInSublimeText 41 | v4.5.1 42 | true 43 | true 44 | true 45 | true 46 | false 47 | 48 | 49 | true 50 | full 51 | false 52 | bin\Debug\ 53 | DEBUG;TRACE 54 | prompt 55 | 4 56 | 57 | 58 | pdbonly 59 | true 60 | bin\Release\ 61 | TRACE 62 | prompt 63 | 4 64 | 65 | 66 | 67 | 68 | 69 | 70 | Component 71 | 72 | 73 | source.extension.vsixmanifest 74 | 75 | 76 | True 77 | True 78 | VSCommands.vsct 79 | 80 | 81 | 82 | 83 | 84 | 85 | Resources\LICENSE 86 | true 87 | 88 | 89 | true 90 | 91 | 92 | true 93 | 94 | 95 | source.extension.vsixmanifest 96 | 97 | 98 | 99 | Designer 100 | VsixManifestGenerator 101 | source.extension.resx 102 | 103 | 104 | 105 | 106 | False 107 | False 108 | 109 | 110 | False 111 | False 112 | 113 | 114 | False 115 | False 116 | 117 | 118 | False 119 | False 120 | 121 | 122 | 123 | 124 | False 125 | False 126 | 127 | 128 | ..\packages\Microsoft.VisualStudio.Imaging.14.3.25407\lib\net45\Microsoft.VisualStudio.Imaging.dll 129 | True 130 | 131 | 132 | ..\packages\Microsoft.VisualStudio.OLE.Interop.7.10.6070\lib\Microsoft.VisualStudio.OLE.Interop.dll 133 | False 134 | 135 | 136 | ..\packages\Microsoft.VisualStudio.Shell.14.0.14.3.25407\lib\Microsoft.VisualStudio.Shell.14.0.dll 137 | True 138 | 139 | 140 | ..\packages\Microsoft.VisualStudio.Shell.Immutable.10.0.10.0.30319\lib\net40\Microsoft.VisualStudio.Shell.Immutable.10.0.dll 141 | False 142 | 143 | 144 | ..\packages\Microsoft.VisualStudio.Shell.Immutable.11.0.11.0.50727\lib\net45\Microsoft.VisualStudio.Shell.Immutable.11.0.dll 145 | False 146 | 147 | 148 | ..\packages\Microsoft.VisualStudio.Shell.Immutable.12.0.12.0.21003\lib\net45\Microsoft.VisualStudio.Shell.Immutable.12.0.dll 149 | False 150 | 151 | 152 | ..\packages\Microsoft.VisualStudio.Shell.Immutable.14.0.14.3.25407\lib\net45\Microsoft.VisualStudio.Shell.Immutable.14.0.dll 153 | True 154 | 155 | 156 | ..\packages\Microsoft.VisualStudio.Shell.Interop.7.10.6071\lib\Microsoft.VisualStudio.Shell.Interop.dll 157 | False 158 | 159 | 160 | True 161 | ..\packages\Microsoft.VisualStudio.Shell.Interop.10.0.10.0.30319\lib\Microsoft.VisualStudio.Shell.Interop.10.0.dll 162 | True 163 | 164 | 165 | True 166 | ..\packages\Microsoft.VisualStudio.Shell.Interop.11.0.11.0.61030\lib\Microsoft.VisualStudio.Shell.Interop.11.0.dll 167 | True 168 | 169 | 170 | True 171 | ..\packages\Microsoft.VisualStudio.Shell.Interop.12.0.12.0.30110\lib\Microsoft.VisualStudio.Shell.Interop.12.0.dll 172 | True 173 | 174 | 175 | ..\packages\Microsoft.VisualStudio.Shell.Interop.8.0.8.0.50727\lib\Microsoft.VisualStudio.Shell.Interop.8.0.dll 176 | False 177 | 178 | 179 | ..\packages\Microsoft.VisualStudio.Shell.Interop.9.0.9.0.30729\lib\Microsoft.VisualStudio.Shell.Interop.9.0.dll 180 | False 181 | 182 | 183 | ..\packages\Microsoft.VisualStudio.TextManager.Interop.7.10.6070\lib\Microsoft.VisualStudio.TextManager.Interop.dll 184 | False 185 | 186 | 187 | ..\packages\Microsoft.VisualStudio.TextManager.Interop.8.0.8.0.50727\lib\Microsoft.VisualStudio.TextManager.Interop.8.0.dll 188 | False 189 | 190 | 191 | ..\packages\Microsoft.VisualStudio.Threading.14.1.131\lib\net45\Microsoft.VisualStudio.Threading.dll 192 | True 193 | 194 | 195 | ..\packages\Microsoft.VisualStudio.Utilities.14.3.25407\lib\net45\Microsoft.VisualStudio.Utilities.dll 196 | True 197 | 198 | 199 | ..\packages\Microsoft.VisualStudio.Validation.14.1.111\lib\net45\Microsoft.VisualStudio.Validation.dll 200 | True 201 | 202 | 203 | False 204 | False 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | Menus.ctmenu 214 | VsctGenerator 215 | VSCommands.cs 216 | Designer 217 | 218 | 219 | 220 | 221 | true 222 | 223 | 224 | 225 | 226 | False 227 | Microsoft .NET Framework 4.5.1 %28x86 and x64%29 228 | true 229 | 230 | 231 | False 232 | .NET Framework 3.5 SP1 233 | false 234 | 235 | 236 | 237 | 238 | True 239 | True 240 | source.extension.vsixmanifest 241 | true 242 | VSPackage 243 | 244 | 245 | 246 | 247 | 248 | 249 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 250 | 251 | 252 | 253 | 254 | 255 | 262 | -------------------------------------------------------------------------------- /src/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.InteropServices; 3 | using OpenInSublimeText; 4 | 5 | [assembly: AssemblyTitle(Vsix.Name)] 6 | [assembly: AssemblyDescription(Vsix.Description)] 7 | [assembly: AssemblyConfiguration("")] 8 | [assembly: AssemblyCompany(Vsix.Author)] 9 | [assembly: AssemblyProduct(Vsix.Name)] 10 | [assembly: AssemblyCopyright(Vsix.Author)] 11 | [assembly: AssemblyTrademark("")] 12 | [assembly: AssemblyCulture(Vsix.Language)] 13 | [assembly: ComVisible(false)] 14 | 15 | [assembly: AssemblyVersion(Vsix.Version)] 16 | [assembly: AssemblyFileVersion(Vsix.Version)] 17 | -------------------------------------------------------------------------------- /src/Resources/Icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/OpenInSublimeText/fff61fec269dba3161143ae60e24dda094f08912/src/Resources/Icon.png -------------------------------------------------------------------------------- /src/Resources/Preview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/OpenInSublimeText/fff61fec269dba3161143ae60e24dda094f08912/src/Resources/Preview.png -------------------------------------------------------------------------------- /src/Resources/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/OpenInSublimeText/fff61fec269dba3161143ae60e24dda094f08912/src/Resources/logo.png -------------------------------------------------------------------------------- /src/Settings.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | using System.IO; 4 | using System.Linq; 5 | using Microsoft.VisualStudio.Shell; 6 | 7 | namespace OpenInSublimeText 8 | { 9 | public class Settings : DialogPage 10 | { 11 | [Category("General")] 12 | [DisplayName("Install path")] 13 | [Description("The absolute path to the \"sublime_text.exe\" or \"subl.exe\" file.")] 14 | public string FolderPath { get; set; } 15 | 16 | [Category("General")] 17 | [DisplayName("Open solution/project as regular file")] 18 | [Description("When true, opens solutions/projects as regular files and does not load folder path into Sublime.")] 19 | public bool OpenSolutionProjectAsRegularFile { get; set; } 20 | 21 | public override void LoadSettingsFromStorage() 22 | { 23 | base.LoadSettingsFromStorage(); 24 | 25 | if (string.IsNullOrEmpty(FolderPath)) 26 | { 27 | FolderPath = FindSublimeText(); 28 | } 29 | } 30 | 31 | private static string FindSublimeText() 32 | { 33 | var programFiles = new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)); 34 | var dirs = programFiles.Parent.GetDirectories(programFiles.Name.Replace(" (x86)", string.Empty) + "*"); 35 | 36 | foreach (DirectoryInfo parent in dirs) 37 | foreach (DirectoryInfo dir in parent.GetDirectories("Sublime*").Reverse()) 38 | { 39 | string path = Path.Combine(dir.FullName, "sublime_text.exe"); 40 | 41 | if (File.Exists(path)) 42 | return path; 43 | } 44 | 45 | return null; 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/VSCommands.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------------------------ 2 | // 3 | // This file was generated by Extensibility Tools v1.10.196 4 | // 5 | // ------------------------------------------------------------------------------ 6 | namespace OpenInSublimeText 7 | { 8 | using System; 9 | 10 | /// 11 | /// Helper class that exposes all GUIDs used across VS Package. 12 | /// 13 | internal sealed partial class PackageGuids 14 | { 15 | public const string guidPackageString = "f5b36ea2-9430-4d77-83dc-c7f6a39e6083"; 16 | public const string guidOpenInVsCmdSetString = "bcea1810-8ea5-45b9-9df0-7ea5baf757cd"; 17 | public const string guidIconsString = "bcea1810-8ea5-45b9-9df0-7ea5baf757ce"; 18 | public static Guid guidPackage = new Guid(guidPackageString); 19 | public static Guid guidOpenInVsCmdSet = new Guid(guidOpenInVsCmdSetString); 20 | public static Guid guidIcons = new Guid(guidIconsString); 21 | } 22 | /// 23 | /// Helper class that encapsulates all CommandIDs uses across VS Package. 24 | /// 25 | internal sealed partial class PackageIds 26 | { 27 | public const int OpenInSublimeText = 0x0100; 28 | public const int FileOpenMenuGroup = 0x0101; 29 | public const int OpenCurrentFileInSublimeText = 0x0102; 30 | public const int Sublime = 0x0001; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/VSCommands.vsct: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 16 | 17 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | -------------------------------------------------------------------------------- /src/VSPackage.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.InteropServices; 3 | using System.Threading; 4 | using System.Threading.Tasks; 5 | using Microsoft.VisualStudio.Shell; 6 | 7 | namespace OpenInSublimeText 8 | { 9 | [PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)] 10 | [InstalledProductRegistration("#110", "#112", Vsix.Version, IconResourceID = 400)] 11 | [ProvideOptionPage(typeof(Settings), "Open in SublimeText", "General", 101, 111, true, new string[0], ProvidesLocalizedCategoryName = false)] 12 | [ProvideMenuResource("Menus.ctmenu", 1)] 13 | [Guid(PackageGuids.guidPackageString)] 14 | public sealed class VSPackage : AsyncPackage 15 | { 16 | public static Settings Settings; 17 | 18 | protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress progress) 19 | { 20 | await JoinableTaskFactory.SwitchToMainThreadAsync(); 21 | 22 | Settings = (Settings)GetDialogPage(typeof(Settings)); 23 | 24 | Logger.Initialize(this, Vsix.Name); 25 | OpenSublimeTextCommand.Initialize(this); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/source.extension.cs: -------------------------------------------------------------------------------- 1 | // ------------------------------------------------------------------------------ 2 | // 3 | // This file was generated by Extensibility Tools v1.10.211 4 | // 5 | // ------------------------------------------------------------------------------ 6 | namespace OpenInSublimeText 7 | { 8 | static class Vsix 9 | { 10 | public const string Id = "2925bbf7-d48b-4abd-83dc-1cd711d9b9ba"; 11 | public const string Name = "Open in Sublime Text"; 12 | public const string Description = @"Adds a menu command that lets you open any solution, project, folder and file in Sublime Text."; 13 | public const string Language = "en-US"; 14 | public const string Version = "1.1"; 15 | public const string Author = "Mads Kristensen"; 16 | public const string Tags = "sublime, text, code"; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/source.extension.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/madskristensen/OpenInSublimeText/fff61fec269dba3161143ae60e24dda094f08912/src/source.extension.ico -------------------------------------------------------------------------------- /src/source.extension.resx: -------------------------------------------------------------------------------- 1 | 2 | 3 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | text/microsoft-resx 110 | 111 | 112 | 2.0 113 | 114 | 115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 116 | 117 | 118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 119 | 120 | 121 | Open in Sublime Text 122 | 123 | 124 | Adds a menu command that lets you open any solution, project, folder and file in Sublime Text. 125 | 126 | 127 | 128 | source.extension.ico;System.Drawing.Icon, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a 129 | 130 | -------------------------------------------------------------------------------- /src/source.extension.vsixmanifest: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Open in Sublime Text 6 | Adds a menu command that lets you open any solution, project, folder and file in Sublime Text. 7 | https://github.com/madskristensen/OpenInSublimeText/ 8 | Resources\LICENSE 9 | Resources\Icon.png 10 | Resources\Preview.png 11 | sublime, text, code 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | --------------------------------------------------------------------------------