How do I make Sublime Text 2 prompt me before exit? - sublimetext2

There have been too many times where I have accidentally clicked the X on the top right window in Sublime Text 2. I then loose my undo/redo history.
Edit: I have tried to set hot_exit to false in default and user settings.

Look for hot_exit in Preferences.sublime-settings
// Exiting the application with hot_exit enabled will cause it to close
// immediately without prompting. Unsaved modifications and open files will
// be preserved and restored when next starting.
//
// Closing a window with an associated project will also close the window
// without prompting, preserving unsaved changes in the workspace file
// alongside the project.
"hot_exit": true,
and set it to false.

Install the plugin Local History.
Every time you modify a file, a copy of the old contents is kept in
the local history.
Either do it through Package Control (If you don't have it already, install it)
Or get it on Github

Related

OllyDbg - there are several patches applied but it still says that file was unmodified and doesn't save changes to modded *.exe

OllyDbg - there are several patches applied but it still says that file was unmodified and doesn't save changes of patches to modded *.exe . Somehow before the addition of each new patch it saves ok with notice of changing the file, but with next it doesn't. And with the third I don't know how to overcome it. How to save them - am I doing something wrong?
The message
Basing on your comments - There is no such Save to file or Edit -> Save to file when you right click in the CPU window. You are doing somethng wrong.
The correct way to save the patches to new file is:
Open CPU window
Right click -> Copy to executable -> All modifications
Click Copy all in the new window
In the new window Right click -> Save file

How to increase the number of concurrent downloads initiated by an extension?

I have an extension which initiates downloads in its background page. The current problem is when you call chrome.downloads.download for, say 100 times, it will download 5 files at a time until all 100 files have been downloaded.
I had same problem with images and I found some answer which works for me:
Press "Windows-R" to open the Run tool. Type "regedit" into the box, click "OK" and then, if prompted, confirm the operation or type your administrator password to open the Registry Editor.
Double-click the "HKEY_CURRENT_USER" directory in the left pane. Double-click the "Software" sub-directory, double-click "Microsoft," double-click "Windows," double-click "CurrentVersion" and then single-click "Internet Settings."
Open the "Edit" menu, move your mouse cursor over "New" and then click "DWORD (32-bit) Value" to create a new registry entry. Name the entry "MaxConnectionsPerServer" (omit the quotes) and double-click it to view its properties.
Select the "Decimal" option from the "Base" section of the "Edit DWORD (32-bit) Value" dialog that opens up. Type the number of simultaneous downloads you want into the "Value Data" box, such as "10" (again, omit the quotes) and click "OK."
Repeat the previous two steps with only one change: This time name the new registry entry "MaxConnectionsPer1_0Server". Close the Registry Editor, close any open programs and restart your computer. The simultaneous download limit change will now go into effect.
For effect I added 650 connections or downloads and it worked for me downloaded 650 pictures from some html file with this code:
var a = document.getElementsByTagName('a');
for(var i=0; i<a.length; i++){
var myimg = a[i].getElementsByTagName('img')[0].src;
a[i].href = myimg;
a[i].download = myimg;
a[i].click();
}
HERE IS THE ANSWER... I almost gave up then I stumbled upon it. Settings >> Advanced >> Downloads >> Unclick "ask where to save each file before downloading". Done! Now you can have virtually unlimited concurrent downloads (given your also using a download manager addon or other). This was on a Mac - no idea how it is handled on Windows.
Unfortunately you can't control that. It's a limitation of chrome's browser. It would be a security issue if you can flood the user's browser with an unlimited number of downloads.

Sublime Text Prompt to Save File

I often will have a scratch pad in ST that I then close via Ctrl-F4. It always prompts me to save it, which I find to be a pain.
Is there a setting in ST where I can either change to default of this dialog to "Close without saving", or do not even prompt me at all if it is a new file (i.e. has no name).
You can set a tab to be a scratch buffer (doesn't prompt to save when closed). With the desired tab opened, open the console with Ctrl` and type:
view.set_scratch(True)
then hit Enter, and close the console with Esc. You can now close the tab whenever you want without being prompted. Of course, you can manually save the contents if you wish.
If you would like to have all new buffers set to scratch by default, you'll need a plugin. Create a new Python file in Sublime with the following contents:
import sublime
import sublime_plugin
class SetNewScratchBuffer(sublime_plugin.EventListener):
def on_new(self, view):
view.set_scratch(True)
def on_save(self, view):
view.set_scratch(False)
Save the file as Packages/User/set_new_scratch_buffer.py where Packages is the folder opened when selecting Preferences -> Browse Packages... (~/.config/sublime-text-2/Packages on Linux with ST2). Once saved, it should automatically become active, although you can restart Sublime to make sure. Now, all new buffers created with CtrlN or File -> New File will automatically have the scratch attribute set. This will be disabled when the file is saved, so you don't accidentally destroy changes to an opened file.

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 Mac Removing Folders on Close

I use Sublime text 2 as my IDE at both work and home. On a windows machine sublime remembers all the folders in the left had column when the programme is closed ect.
However on my mac using sublime removes the folders as soon as that window is closed.
Does anyone know how to fix this?
This option should be under Sublime Text 2 -> Preferences -> Settings – Default
// Exiting the application with hot_exit enabled will cause it to close
// immediately without prompting. Unsaved modifications and open files will
// be preserved and restored when next starting.
//
// Closing a window with an associated project will also close the window
// without prompting, preserving unsaved changes in the workspace file
// alongside the project.
"hot_exit": false,
// remember_open_files makes the application start up with the last set of
// open files. Changing this to false will have no effect if hot_exit is
// true
"remember_open_files": false,