Showing posts with label Sublime. Show all posts
Showing posts with label Sublime. Show all posts

Sunday, January 10, 2016

Sublime Text 3 unhiding menu in Ubuntu - simpler solution

The method which I mentioned in this blog post of mine, solves the problem, but then you have to
  1. Close the Sublime Text
  2. Fire up a terminal
  3. Execute a command or two
  4. Open Sublime Text again
Quite a lot of steps to do. But then I found a simpler solution today and it works like a charm for me. The solution is to use "Keyboard Shortcuts" :-) Let me explain in detail.
  1. Click Preferences -> Key Bindings - User
  2. In the window that opens, you need to add a new keyboard shortcut for the command "toggle_menu". For example, this is how my shortcuts looks like
    [{"keys": ["ctrl+\\"], "command": "toggle_side_bar"},
     {"keys": ["ctrl+shift+m"], "command": "toggle_menu"}]
  3. Save the file and start doing your happy dance.
Now, you can simply press the keyboard shortcut whatever you choose to assign to toggle menu :-)

Sunday, January 5, 2014

Un-hiding Menu Bar in Sublime Text 3 - Ubuntu

Edit on 13-Jan-2016
I found another easy way to fix this problem. You can toggle the menu with a keyboard shortcut. You can read more about that in this blog post of mine.


It has been a very long wait to get the "Hide Menu" feature in Linux versions of Sublime Text 3. Finally it was released. But the problem is, if it hidden once, there is no straight forward way to get the Menu back. I tried F10, Alt etc etc and nothing worked. So, I am sharing the trick which worked for me in this post.

It is simple. Close the Sublime Text 3, if it is open. Open

~/.config/sublime-text-3/Local/Session.sublime_session
in any of your favorite editors and then make sure that, "menu_visible" is "true" in all places in that file.
"menu_visible": true,
Thats it :) Open Sublime Text 3 now and ta-da... Menu is back :)


Edit On Jan 10 - 2016

As I was doing the same task more often, I decided that put that in a script, like this

export FILE=/home/thefourtheye/.config/sublime-text-3/Local/Session.sublime_session
export TEMP_FILE=/home/thefourtheye/.config/sublime-text-3/Local/Session.sublime_session.bkp
sed -e 's/"menu_visible": false/"menu_visible": true/g' $FILE > $TEMP_FILE
mv $TEMP_FILE FILE
and then I added that to my shell script's rc file as an alias like this
alias sublime_fix_menu=~/.sublime_fix_menu.zsh
That's it :-) Now, I just have to close Sublime Text 3, type sublime_fix_menu in the shell, open Sublime again :-)

Monday, July 29, 2013

Compiling Node.js scripts in Windows 7 with Sublime Text 3

This is a continuation of Compiling CPP 11 Programs with Sublime Text 3 in Ubuntu where we saw how to configure Sublime Text 3 in Ubuntu 13.04 to compile C++ 11 programs. In this post, we ll see how to execute Node.js programs in Windows 7 machine's Sublime Text 3. I am going to assume that Node.js is installed properly and PATH variable is also set properly. If you are using Windows Installer, we dont have to worry about this.

  1. We need to create the following directory structure in the User's home directory AppData\Roaming\Sublime Text 3\Packages\JS\. In my machine, home directory is C:\Users\[username]. To know the current user's home directory, open Cmd.exe and type echo %userprofile%.
  2. In that directory, create a file called "JS.sublime-build". So, the location of the file from the home directory is AppData\Roaming\Sublime Text 3\Packages\JS\JS.sublime-build You can name the sublime-build file as anything you want. I have simply named it here as JS.
  3. Copy and paste the following text in to it.
    {
     "cmd": ["node.exe", "${file}"],
     "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
     "working_dir": "${file_path}",
     "selector": "source.js",
     "variants":
     [
      {
       "name": "Run",
       "cmd":["node.exe", "${file}"]
      }
     ]
    }
    
  4. Thats it. Open Sublime Text 3. Click on Tools->Build System. You should see JS as one of the options. From now on, you can execute node.js scripts simply by pressing Ctrl-B.

Sunday, July 21, 2013

Compiling C++11 Programs with Sublime Text 3

For Windows 7, you may want to read this post http://www.thefourtheye.in/2013/07/Compiling-Node.js-scripts-in-Windows-7-with-Sublime-Text-3.html

Today I installed Sublime Text 3's public beta on my Ubuntu 13 and the first thing I noticed is, the inability to compile C++ 11 programs. The obvious problem is, it was missing -std=c++0x parameter to g++. I tried to figure out how to edit the build parameters of Sublime. After an hour's struggle managed to figure out.

  1. You need to create the following file ~/.config/sublime-text-3/Packages/C++/C++.sublime-build. The ~ refers to the home directory of the current user.
  2. Now insert the below seen text to that file
    {
     "cmd": ["g++", "-std=c++0x", "${file}", "-o", "${file_path}/${file_base_name}"],
     "file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
     "working_dir": "${file_path}",
     "selector": "source.c, source.c++",
     "variants":
     [
       {
         "name": "Run",
         "cmd":["bash", "-c", "g++ -std=c++0x '${file}' -o '${file_path}/${file_base_name}' && '${file_path}/${file_base_name}'"]
       }
     ]
    }
    
  3. Save this file and close it. Sublime will pick up the changes immediately.
This will take care of compiling C++ 11 programs.

Saturday, May 25, 2013

Sublime Configuring CodeIntel Auto Completion

Unarguably Sublime is one of the best text editors and with its ability to extend with python scripts, gifts itself a lot of power. Here lets see one of those extensions which allow code completion. Normally, sublime provides code completion for the words in the current file being edited. Codeintel allows the user to get code completion feature of the respective languages.

Installation

Lets install CodeIntel, through Package Control plugin. To install Package Control plugin, do the following steps. Here is the author's page. Quoting from the source website

Installation is through the Sublime Text 2 console. This is accessed via the ctrl+` shortcut. Once open, paste the following command into the console.

import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print('Please restart Sublime Text to finish installation')

After installing it, Press Shift+Ctrl+P or click on Tools->Command Palette. In the window that opens up, type Install Package. In the text box which you see after that, type SublimeCodeIntel and click on it to install it. You are done with the installation of CodeIntel.

Configuration

The following information is taken from the README.rst file. Open ~/.codeintel/config file in your favourite text editor, most likely Sublime. Pick your language from the list below and copy paste only the blocks for the languages of your choice.

    {
        "PHP": {
            "php": '/usr/bin/php',
            "phpExtraPaths": [],
            "phpConfigFile": 'php.ini'
        },
        "JavaScript": {
            "javascriptExtraPaths": []
        },
        "Perl": {
            "perl": "/usr/bin/perl",
            "perlExtraPaths": []
        },
        "Ruby": {
            "ruby": "/usr/bin/ruby",
            "rubyExtraPaths": []
        },
        "Python": {
            "python": '/usr/bin/python',
            "pythonExtraPaths": []
        },
        "Python3": {
            "python": '/usr/bin/python3',
            "pythonExtraPaths": []
        }
    }

For example, I like to use python and my config file looks like this
{
 "Python": {
     "python": '/usr/bin/python',
     "pythonExtraPaths": []
 },
}

Thats it. Restart your sublime, type code and press Alt + / to see the Auto completion at work.