Sublime Text 2 Plugin to Convert Tabs to Spaces on Save

Here is a simple Sublime Text 2 plug-in to convert tabs (only at the beginning of lines) to spaces in the current file whenever you save it.

In Sublime, go to the Preferences menu and choose Browse Packages… This will open the Sublime Text 2 Packages folder. Create a new folder here with your last name, then open your new folder (you just created your own Package!)

Next, create an empty file in the folder called “”. Paste this code into the file:

import sublime, sublime_plugin

# class ExampleCommand(sublime_plugin.TextCommand):
#   def run(self, edit):
#       self.view.insert(edit, 0, "Hello, World!")

class ConvertTabsToSpaces(sublime_plugin.EventListener):
    def on_pre_save(self, view):
        edit = view.begin_edit()
        view.run_command('expand_tabs', {"set_translate_tabs": True})
        #sublime.message_dialog("Converted endings.")

This creates a hook and runs whenever you save the file, but right before the save actually occurs, allowing you to modify the document text. In this case all we did was run the menu command “expand_tabs”. You could also run other commands or perform custom text replacements.

How to mount a DVD ISO as a drive in Ubuntu Linux

No additional software required. First, create a directory in which to mount the ISO.

mkdir -p ~/media/iso

Then, to mount it:

sudo mount -o loop /home/path/to/my_fun_dvd.iso ~/media/iso
nautilus ~/media/iso

The last line is to open the mounted directory in a visual file browser called Nautilus.

If you end up doing this often, you can create a bash function. Put this at the end of your ~/.bashrc file:

function mountcd {
sudo mount -o loop $1 ~/media/iso

Save the file, reload it in bash using this command

. ~/.bashrc

That’s (period)(space)~/.bashrc — the period is a command in bash that reloads the script file without having to launch the terminal again.

Now you can do this in the terminal:

mountcd ~/Downloads/my_cool_dvd.iso

And your DVD ISO will be ready for viewing in the ~/media/iso directory (the tilde character means your home directory, /home/john). In Ubuntu 12, by opening the folder containing the DVD files, it will prompt you to open with VLC media player: