"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How Can I Get User Input in Sublime Text 2?

How Can I Get User Input in Sublime Text 2?

Published on 2024-11-17
Browse:937

How Can I Get User Input in Sublime Text 2?

User Input in Sublime Text 2

Users encounter difficulties when attempting to input values in Sublime Text 2, particularly when using functions like input() in Python or gets in Ruby. The console doesn't prompt for input, leading to errors like EOFError.

The issue arises from Sublime Text 2's lack of native support for console input. Fortunately, a workaround exists using SublimeREPL, a package that integrates a REPL (Read-Eval-Print Loop) into Sublime Text.

Installing SublimeREPL:

  1. Install Package Control to easily install plugins.
  2. Open Sublime Text and press Ctrl Shift P.
  3. Type "install" and select "sublime package control: install package."
  4. Search for SublimeREPL and install it.

Using SublimeREPL:

  1. Go to Tools > sublimerepl > Python to run Python in a REPL tab.
  2. Type your code and press Enter. The input prompt will now appear in the REPL tab.

Making SublimeREPL the Default Build System:

  1. Open Preferences > Settings - User.
  2. Add the following lines:
"sublime_re_install_default_build": true,
"sublime_re_use_for_current_project": true

This will set SublimeREPL as the default build system for all projects.

By utilizing SublimeREPL, users can provide user input in Sublime Text 2, eliminating the need to rely on external terminals or custom setups.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3