Sublime text Autosave only for specific files - sublimetext2

I don't want to hit cmd+s all day when I code a web UI using Sublime Text 2.
SCENARIO:
Sublime Text with LiveStyle plugin
Google Chrome with Live Style addon
WHAT I DON'T WANT:
Hitting cmd+s every time I edit an html/js/css file
Applying a global autosave solution like "save_on_focus_lost": true to all files of a project (e.g. python or php files shouldn't be autosaved)
WHAT I WANT:
Autosave and automatically reload only certain files of my project in Chrome (thanks to LiveStyle)
QUESTION:
How to selective apply an autosave setting (or plugin) like "save_on_focus_lost": true only to certain files within a project?
Any alternative solution is welcome

Don't know anything about LiveStyle, so I'll speak to the autosaving specifically. If it's all files of a particular type, you can create a syntax specific setting. If it isn't you can write a plugin that ties into the on_load or on_activated event. When this event is triggered, you can apply a setting to the view. Assuming you have the view, you can do something like view.settings().set("save_on_focus_lost", True) in the plugin.

Related

Navigate back and forth between recently opened files

Is there a keyboard shortcut in Sublime to navigate back and forth between recently opened files? Something like Alt+Right and Alt+Left (an example from Eclipse or web browsers). If not, is there a way to create a custom shortcut like this?
You can use the following shortcuts to navigate through different open files:
CTRL+PAGE UP Cycle up through tabs in taborder
CTRL+PAGE DOWN Cycle down through tabs in taborder
CTRL+TAB Next recently used file
CTRL+SHIFT+TAB previous recently used file
More Shortcuts for sublime can be found here.
Custom shortcuts
Go to Preferences > Key Bindings-Default and find the binding that you need and copy the command. The next step is to open references > Key Bindings-User where you paste and edit the command.
More concrete info about custom shortcuts can be found here.
It is possible if you still have them opened. Other than that
That's CTRL+TAB / CTRL+SHIFT+TAB.
Other than that, if you need to have possibility to open recently closed files, you may try doing it with CTRL+SHIFT+T (open last closed tab), try this package out or even visit this thread and see if it still works.
If you have a large number of files open, you can use ctrl + P, and use GoToAnything.
Unofficial doc information

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.

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

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.

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)

How to edit preference file for Notepad++?

My open source project uses spaces, not tabs, in its code.
A contributor to the project has his own website which uses tabs, not spaces.
He uses Notepad++ in Windows to edit files for both projects, and is frustrated when he forgets to manually set the Preferences correctly and thus inserts tabs into my project's files.
Is there a way to edit this Preference via a script? That way he could click one icon to start Notepad++ in mode 1 (running a batch script to modify the Preferences file and then start the program) or click another to start in mode 2.
Or if there's any other way to make him not have to remember this chore, that would work too. Maybe having a Preferences setting that depends on what folder the edited file is inside of?
Any help would be appreciated. Thanks!
The notepad++ setting for replacing tabs with spaces is stored in following xml file
%USERPROFILE%\Application Data\Notepad++\config.xml
The following is the line that needs to be changed
<GUIConfig name="TabSetting" size="4" replaceBySpace="yes" />
Now I don't know how we can edit a file by batch script in windows, but if it is not possible, then he can keep two config files config-tabs.xml and config-spaces.xml. And in the script you can copy appropriate file depending on what he needs to work on.