Sublime text 2 - Zip open files with full path name and dir structure - sublimetext2

Is there a plugin or a macro, that creates a tar ball or a zip of all opened files / tabs in Sublime Text 2.
If not, how to make a plugin that does that?
I was checking the API of Sublime Text 2, only to know that there is no method that gets the full path of all open files.
However, I see that we have an option when we right click in any file - "Copy file path".
Which method it calls? Can I replicate the method to all tabs switching one by one? If yes, then how to cycle through open tabs one by one using the API?

You can use window#views to get all the views (as a list). Then iterate on each view and use view#file_name to get the files. As for creating zips, take a look at the zipfile library.
For your particular case, I would create a window command. You can then bind that to a key combination or add it as a command palette entry. Finally, to set the visible view, you can use window#focus_view. You may also need window#focus_group if you have multiple groups.

Related

PhpStorm searching in project tool window

I'm using PhpStorm 10.0.4
When I start typing characters in project tool window it searchs for files containing typed text.
Is it possible to change this behavior so only files that begins with typed text would be matched?
Is it possible to change this behavior so only files that begins with typed text would be matched?
AFAIK no. There are no GUI settings for this at all.
Plus, this Speed Search is used in many places/tool windows and search logic is the same.
P.S. If you need to search for files .. why not try more appropriate (in general sense) Navigate | File... instead?
Speed Search only finds items in already expanded nodes (as it's a basic search on already displayed text) .. but Navigate | File... will look for files everywhere in the project.
It's not possible directly but you can create and use a scope for that.
Open Settings and go the Appearance & Behaviour -> Scopes. Create a new scope, give it a name (let's say "My Files") and put file:*/c* in the Pattern edit box.
In the big list of files under the Pattern edit box you can preview its effects. The files that are included in the scope are colored in green, the directories that contain included files are colored in blue.
This simple pattern selects only the files whose name start with c, in all directories. You can use slightly more complex filters using wild cards, include or exclude entire directories etc. With a little practice you can create filters that match usual needs pretty well.
When you are pleased with the scope definition, close the Settings box and go back to the Project view. Click on the arrow next to Project and you'll get a list of views of the project files. All the scopes you created should be there. Select "My Files" and only the files (and directories) included in that scope will be displayed in the Project view.
It is not a dynamic filter, you have to work a little to set it up, but it is useful when you work on large projects, with thousands of files, and you need to hide the files not important for your task.

Is there a way to open a file in split view from recent files popup

I have this Recent files popup:
I can open any file from it by pressing ENTER. Is there any way to open the file in a split view? I have tab limit set to 1, so opening a file from Recent files and then opening it in a split view replaces the currently open file. I'd like to open a file in a split view without replacing the current tab. Maybe key mapping somehow?
Unfortunately not (as far as my knowledge goes).
https://youtrack.jetbrains.com/issue/IDEA-108556 -- watch this and related tickets (star/vote/comment) to get notified on any progress.
The only other possible options (generally speaking):
Shift + Enter to open it in a new/detached editor.
Open as usual and then use Move Down or Move Right to move it in that split group (will create if you do not have one). But this will NOT work if you set to have only 1 editor tab max.
Open as usual, clone it to bottom/right side (so it opens in both splitters) and then re-open recently closed file in one of the split areas again (yeah .. long and inconvenient).
Move focus to another splitter before invoking Recent Files (if you have no such splitter yet -- create one for current file). Now chose file as usual -- it will replace file in current splitter (inconvenient as you need to think about correct location in advance instead of quickly opening the needed file).

How to say to PhpStorm/WebStorm where the including file resides?

Any web project consists of lots of partials that are included into the main file. Very often IDE (PhpStorm for my case) doesn’t know where the including partial resides. The thing is sometimes we use absolute path (e.g. in AngularJS to specify where views’ or directive’s templates reside) and relative path in preprocessors’ sources (jade, stylus, coffee, etc.). And all these files can be stored somewhere in the folder structure.
Therefore very often you can’t to open the including file right from the main file using Ctrl+B.
I think there is a way to tell IDE where this file actually resides. Does anybody know how to cope with it?
If there is no way, I suppose we should ask the developer to solve it somehow.
Depending on the particular framework in which you're developing, a PhpStorm plugin might exist to make CTRL+B navigation possible. For instance, using the Symfony plugin (installed via Settings > Plugins), CTRL+B navigation into a partial template becomes possible in code like this:
return $this->render('hello/world/index.html.twig');
If a plugin is not available, try the following steps. It's not a perfect solution, but it's better than nothing! It's also extremely quick once you get the hang of it.
With your cursor inside the string containing the path and filename, use the 'Extend Selection' keyboard shortcut until the entire string is highlighted (excluding any wrapping single/double quotes). If you don't currently have the 'Extend Selection' action mapped, you can do so via Settings > Keymap.
Immediately use the 'Navigate to File' shortcut (CTRL+SHIFT+N) to search for all files matching the path/filename contained in the string you previously highlighted.
A dropdown box will appear containing all matching files. Find the proper one and open it using ENTER.

How to edit multiple files through "Find results" in Sublime Text

When I search multiple files via Command + Shift + F, the result is returned as something like a text file. This text file is editable, but changes made don't affect the original files.
Is it possible to do such that changes in "Find Results" propagates to the original source file?
The Find Results Apply Changes plugin was created to do just that.
You can install it through Package Control's "Install Package" option.
Before using this plugin, make sure that you have UTF-8 encoding enabled using the menu:
File > Save with Encoding > UTF-8
Once installed, you can apply any change you made to a "Find Results" buffer back to the files:
Search for "foo" in a folder (Sublime's default shortcut is CTRL+SHIFT+S)
This will open a "Find Results" buffer listing all the files with "foo" in it.
Change the instances of "foo" for "bar" or something else...
Go to the menu:
Find > Find Results - Apply Changes
This will write all the changes made back to the files and save the modified files automatically.
By default, using menus is the only way to make it work. However, it is quite tiresome and doesn't save as much time as it does with a keyboard shortcut. You can set your chosen keyboard shortcut by adding a new line in
Preferences > Key Bindings - User
by adding:
{ "keys": ["ctrl+r"], "command": "find_results_apply_changes" },
Don't use CTRL+S as it will overwrite saving file shortcut.
Warning!: According to the author of the plugin:
Uses regions to allow you do multiline changes, but when inserting new
newlines, will corrupt files if you commit more than once, this
because the new newlines will shift the line numbers. Will also
'corrupt' files if you add/remove newlines in other instances of the
modified files. eg in another tab. To prevent corruption this packages
will alert you and prevent most of these.
(This is a modified version of the description from the Find Results Apply Changes Github page.)
The shortest workaround I can think of would be to open the target file from search results by simply double clicking the path and then jumping to the according line using Ctrl+G on Windows or ⌃+G on Mac OS.
That's the way I do it and must say it is only a matter of seconds, even without the plugin.

IntelliJ IDEA compare tabs

I'm using IDE 10.5 Community edition.
In one project, I have multiple modules. I also have opened multiple tabs in the editor from different modules.
Is there a way to compare the content of two different tabs in the editor, which can be from different modules?
Select two files (with pressed Ctrl) in project view panel → Right Mouse button → Compare Files.
Right click on the file in project view → Compare With... (Ctrl+D)
If you have opened one file in editor you can navigate in project view to another file and press right mouse button on that file Compare with Editor.
It is possible to compare file against your clipboard content. View → Compare With clipboard
Also you can use idea as external diff tool idea diff file1.txt file2.txt
Outdated; Old verison of IntelliJ: Also you can compare files from 'Commander' tab, just select two files in right and left panels, right click on any of them → Compare two files
There is a plugin Compare Tab With Editor which may not have existed when this question was asked. I'm using it with IntelliJ 2017.2.
There is an updated version for IDE versions 2020.3 — 2022.1, Compare Tab With Editor 2.
One simple solution is the 'Compare with Clipboard' function (in your contextual menu - right click), which allows you to compare the contents of an editor tab with whatever is in your clipboard. As long as you can copy something, you can compare it against a file...
In 2019, select your file and "compare with editor" (which is your opened tab)
I use this to have a config file loaded in intelliJ (which is changed by the server, not stored in my project) and need to compare it to a baseline (in my project)