ctrl+shift+p filters: :st2 :st3 :win :osx :linux
Browse

Sublime Input

by mavidser ALL

Send STDIN input to programs using comments in Sublime Text 2/3

Details

Installs

  • Total 23K
  • Win 15K
  • Mac 4K
  • Linux 4K
May 12 May 11 May 10 May 9 May 8 May 7 May 6 May 5 May 4 May 3 May 2 May 1 Apr 30 Apr 29 Apr 28 Apr 27 Apr 26 Apr 25 Apr 24 Apr 23 Apr 22 Apr 21 Apr 20 Apr 19 Apr 18 Apr 17 Apr 16 Apr 15 Apr 14 Apr 13 Apr 12 Apr 11 Apr 10 Apr 9 Apr 8 Apr 7 Apr 6 Apr 5 Apr 4 Apr 3 Apr 2 Apr 1 Mar 31 Mar 30 Mar 29 Mar 28
Windows 1 3 7 3 1 8 6 2 6 6 6 2 5 4 9 8 3 2 6 8 5 4 1 4 7 4 3 5 5 2 5 7 1 5 7 5 4 3 5 6 6 6 3 4 2 0
Mac 0 0 3 0 0 0 0 0 0 2 1 0 2 0 1 0 3 2 1 2 0 0 1 0 1 0 0 3 1 0 2 0 1 1 0 2 4 3 0 0 0 0 0 1 1 3
Linux 0 0 1 0 0 1 0 0 1 0 0 1 2 1 2 1 0 1 0 2 1 1 0 1 0 1 0 2 3 1 0 0 1 1 0 0 2 2 0 2 0 1 0 0 0 2

Readme

Source
raw.​githubusercontent.​com

Sublime Input

Sublime Input is a Sublime Text 2/3 plugin which gives STDIN input through comments to a program.

Installation

With the Package Control plugin (Recommended):

  1. Bring up the Command Palette (Cmd+Shift+P on OS X, Ctrl+Shift+P on Linux/Windows).
  2. Select “Package Control: Install Package”, wait while Package Control fetches the latest package list, then select Sublime Input.
  3. The advantage of using this method is that Package Control will automatically keep Sublime Input up to date with the latest version.

Alternate Method:

  1. Go to Preferences | Browse Packages
  2. Browse up a folder and then into the Installed Packages/ folder
  3. Downlad and Sublime.Input.sublime-package file
  4. Rename the Sublime.Input.sublime-package file to Sublime Input.sublime-package
  5. Put the Sublime Input.sublime-package file in the Installed Packages/ folder
  6. Restart Sublime Text

Usage

Insert a multi-line comment at the top of program.

Examples, using the default format:

Python:

'''input
2
foo
bar
'''
a=input()
for i in xrange(a):
    a=raw_input()
    print a

C/C++

/*input
2
foo
bar
*/
#include <stdio.h>
int main() {
  int n,i;
  char s[10];
  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%s",s);
    printf("%s\n",s);
} }

Both the programs will print the following output:

foo
bar

Configure

Set the build schemas in Preferences: Package Settings > SublimeInput > Settings – User

Example schema :

{
  "build_schemas" : {
    "cpp" : {
      "shell_cmd" : "g++ \"${file}\" -o \"${file_path}/${file_base_name}\" && \"${file_path}/${file_base_name}\"",
      "input_start" : "/*input",
      "input_end" : "*/"
    }
  }
}

build_schemas contains key-value pairs, where the key's the filetype (cpp in this example), and a dictionary as its value.

shell_cmd stores the command to execute on build.

{file} - Complete address of the file

{file_path} - The address of the directory the file is stored in

{file_base_name} - Just the filename, without the extension

{file_extension} - The extension of the file

input_start stores the start of the input comment block.

input_end stores the end of the input comment block.

The default schema can be found in Preferences: Package Settings > SublimeInput > Settings – Default

The following schemas have been included by default: - C - C++ - Python - Java

Keyboard Shortcuts

  • Ctrl + Alt + B - Build/Run program
  • Ctrl + Alt + C - Cancel the running pogram

Current Status

The Plugin is in active development. Windows users may encounter some bugs.