Sublime Text 2 Console Input

Sublime Text 2 console input

Sublime text doesn't support that. But you can get around it (at least in python) by using SublimeREPL, I use this for everything, it works pretty great. Its a little cooky though, as the tab is still editable like a normal sublime tab (which is good and bad)...

It also allows you to run the interpreter in multiple tabs, its basically awesome.

To install it you need package control this lets you easily install plugins. To get it go here, and follow the instructions. Once thats done:

  • in Sublime press ctrl + shift + P (linux command in ST for 'goto anything').
  • Type in 'install',
  • click on 'sublime package control: install package'.
  • Then select SublimeREPL. It will install it automatically.
  • To use it go to Tools>sublimerepl>python from the menus.

To make the default build system SublimeREPL, you can follow these instructions.

Java console input in Sublime Text 2?

Okay, I've figured out a complete and perfect solution to this "Run java in Sublime" problem, I've only tested this in Windows 7.

By following the steps below, you will have 2 Build Systems in sublime - "JavaC" and "JavaC_Input".

  • "JavaC" would let you run code that doesn't require user input and display the results in sublime's terminal simulator, which is convenient and nice-looking.

  • "JavaC_Input" lets you run code that requires user input in a separate terminal window, it's able to accept user input. You can also run non-input-requiring code in this build system, so if you don't mind the pop-up, you can just stick with this build system and don't switch.

You switch between build systems from Tools -> Build System. And you compile&run code using ctrl+b.

Here are the steps to achieve this:

(note: Make sure you already have the basic setup of the java system: install JDK and set up correct CLASSPATH and PATH, I won't elaborate on this)

"JavaC" build system setup

1, Make a bat file with the following code, and save it under C:\Program Files\Java\jdk*\bin\ to keep everything together. Name the file "javacexec.bat".

@ECHO OFF
cd %~dp1
javac %~nx1
java %~n1

2, Then edit C:\Users\your_user_name\AppData\Roaming\Sublime Text 2\Packages\Java\JavaC.sublime-build (if there isn't any, create one), the contents will be

{
"cmd": ["javacexec.bat", "$file"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.java"
}

"JavaC_Input" build system setup (mainly the same as @lac_dev 's answer)

1, Install Cygwin [http://www.cygwin.com/]

2, Go to C:\Users\your_user_name\AppData\Roaming\Sublime Text 2\Packages\Java\, then create a file called "JavaC_Input.sublime-build" with the following content

{
"cmd": ["javacexec_input.bat", "$file"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.java"
}

3, Make a bat file with the following code, and save it under C:\Program Files\Java\jdk*\bin\ to keep everything together. Name the file "javacexec_input.bat".

@echo off
javac -Xlint:unchecked %~n1.java
start cmd /k java -ea %~n1

Console for Sublime Text 2

You're looking for a combination of scriptcs, scriptcs-sublime and SublimeREPL. They will let you write and execute C# code inside Sublime Text easily.

Steps to install:

  1. Install chocolatey (like apt-get for Windows) by running the following PowerShell command:

    @powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object
    net.webclient).DownloadString('https://chocolatey.org/install.ps1'))"
    && SET PATH=%PATH%;%systemdrive%\chocolatey\bin

  2. Install scriptcs by running the following command in your CLI

    cinst scriptcs

  3. Install Sublime Package Control (if you don't have it already). You can find the installation guide here.

  4. Go to Menu > Tools > Command Palette and type Install Package, then find and install

    1. scriptcs
    2. SublimeREPL
  5. Restart Sublime

  6. Go to Menu > Tools > Command Palette and select SublimeREPL: ScriptCS.

You should now be running the scriptcs REPL inside Sublime Text :)

scriptcs REPL in Sublime

User input in sublime text 2 extension

You can use show_input_panel method described here.



Related Topics



Leave a reply



Submit