How to run code in atom

How to run code in atom

How to run a program in Atom Editor?

I found Atom editor as good free alternative to Sublime text editor. Not able to find a straightforward way to run a program in Atom editor. In my case, I am trying to run a java program. Please let me know if it’s possible? If yes, please describe the steps to follow.

How to run code in atom. Смотреть фото How to run code in atom. Смотреть картинку How to run code in atom. Картинка про How to run code in atom. Фото How to run code in atom

How to run code in atom. Смотреть фото How to run code in atom. Смотреть картинку How to run code in atom. Картинка про How to run code in atom. Фото How to run code in atom

9 Answers 9

Trending sort

Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.

It falls back to sorting by highest score if no posts are trending.

Switch to Trending sort

I find the Script package useful for this. You can download it here.

Once installed you can run scripts in many languages directly from Atom using cmd-i on Mac or shift-ctrl-b on Windows or Linux.

How to run code in atom. Смотреть фото How to run code in atom. Смотреть картинку How to run code in atom. Картинка про How to run code in atom. Фото How to run code in atom

You can go settings, select packages and type atom-runner there if your browser can’t open this link.

For C / C++ programs there’s very good package gpp-compiler.

Shortcuts:

How to run code in atom. Смотреть фото How to run code in atom. Смотреть картинку How to run code in atom. Картинка про How to run code in atom. Фото How to run code in atom

If you know how to launch your program from the command line then you can run it from the platformio-ide-terminal package’s terminal. See platformio-ide-terminal provides an embedded terminal within the Atom text editor. So you can issue commands, including commands to run your Java program, from within it. To install this package you can use APM with the command:

Alternatively, you can install it from the command palette with:

How to run code in atom. Смотреть фото How to run code in atom. Смотреть картинку How to run code in atom. Картинка про How to run code in atom. Фото How to run code in atom

This package in Atom can run scripts.

press Alt+X for the running script.
For running javascript you need to install ‘node js’

Also pressing ctrl+shift+i in atom gives developer option like chrome

you can test javascript code side by side in atom editor.

Script

How to run code in atom. Смотреть фото How to run code in atom. Смотреть картинку How to run code in atom. Картинка про How to run code in atom. Фото How to run code in atom

Run code in Atom!

Run scripts based on file name, a selection of code, or by line number.

How to run code in atom. Смотреть фото How to run code in atom. Смотреть картинку How to run code in atom. Картинка про How to run code in atom. Фото How to run code in atom

Currently supported grammars are:

NOTE: Some grammars may require you to install a custom language package.

You only have to add a few lines in a PR to support another.

Installation

apm install script

Search for script within package search in the Settings View.

Atom can’t find node | ruby | python | my socks

Make sure to launch Atom from the console/terminal. This gives atom all your useful environment variables. Additionally, make sure to run it with the project path you need. For example, use

to get it to run with the current directory as the default place to run scripts from.

Usage

Make sure to run atom from the command line to get full access to your environment variables. Running Atom from the icon will launch using launchctl’s environment.

Script: Run will perform a «File Based» run when no text is selected (default).

Script: Run while text is selected will perform a «Selection Based» run executing just the highlighted code.

Script: Run by Line Number to run using the specified line number. Note that if you select an entire line this number could be off by one due to the way Atom detects numbers while text is selected.

Also, in this dialog you can save options as a profile for future use. For example, you can add two profiles, one for python2.7 and another for python3 and run scripts with a specified profile, which will be more convinient than entering options every time you want to switch python versions.

Script: Run With Profile allows you to run scripts with saved profiles. Profiles can be added in Script: Run Options dialog.

Script: Kill Process will kill the process but leaves the pane open.

Script: Close View closes the pane and kills the process.

To kill everything, click the close icon in the upper right and just go back to coding.

Script: Copy Run Results copies everything written to the output pane to the clipboard, allowing you to paste it into the editor.

Command and shortcut reference

CommandmacOSLinux/WindowsNotes
Script: Runcmd-ishift-ctrl-bIf text is selected a «Selection Based» is used instead of a «File Based» run
Script: Run by Line Numbershift-cmd-jshift-ctrl-jIf text is selected the line number will be the last
Script: Run Optionsshift-cmd-ishift-ctrl-alt-oRuns the selection or whole file with the given options
Script: Run with profileshift-cmd-kshift-ctrl-alt-bRuns the selection or whole file with the specified profile
Script: Close Viewesc or ctrl-wescCloses the script view window
Script: Kill Processctrl-cctrl-qKills the current script process

Replacements

The following parameters will be replaced in any entry in args (command and program arguments). They should all be enclosed in curly brackets <>

Parameters are compatible with atom-build package.

Development

Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit.

As for coding and contributing, rely on the atom contributing guidelines. They’re pretty solid.

Quick and dirty setup

apm develop script

This will clone the script repository to

/github unless you set the ATOM_REPOS_HOME environment variable.

I already cloned it!

Workflow

I think this package is bad news.

Good catch. Let us know what about this package looks wrong to you, and we’ll investigate right away.

Настройка Atom от GitHub для работы с PHP, Python и некоторыми другими языками программирования

Изначально считаем что у Вас установлена поддерживаемая операционная система, Node.JS и Atom. В примерах мы работаем в OpenSUSE (13.1) в нём (и вообще в дистрибутивах *nix) уже «из коробки» обычно есть не только Python но PHP и другие языки программирования. Так же исправно работает на Ubuntu (>12.04). Если у Вас Windows 7 или 8, а раньше Вы с ними (языками) не работали то их предварительно необходимо скачать и установить.
Примечание: перед началом работы желательно запускать Atom под root.
опыт показывает — работает стабильнее

Linter

Идеология Atom к подсветке в том, что основным пакетом для работы с синтаксисом и его анализа будет Linter, который является верхним уровнем в API для других линтеров кода. Это сделано для прекращения «войны между плагинами» (The idea is to stop the linter plugins war, by providing a top level API for linters to parse and display errors in the Atom editor). Тем не менее, не все сторонние разработчики придерживаются этой идеологии и пишут свои плагины.

How to run code in atom. Смотреть фото How to run code in atom. Смотреть картинку How to run code in atom. Картинка про How to run code in atom. Фото How to run code in atom

Пакет Script: запуск программ из Atom

Script — пакет для запуска кода в atom.

Установка пакета Script, возможна из командной строки:

или меню
Packages->Settings View->Install->Packages

Каждый язык работает, при наличии предварительно установленного компилятора / интерпритатора.
Пакет Script обновляется довольно часто. Например поддержка Swift появилась менее двух недель назад. Так что скорее всего в ближайшее время появится поддержка новых языков.

Для запуска программы необходимо выбрать
Packages—>Script—>Run

How to run code in atom. Смотреть фото How to run code in atom. Смотреть картинку How to run code in atom. Картинка про How to run code in atom. Фото How to run code in atom

Дополнительные опции можно найти в документации либо на страницах Atom`а или проекта.

Для функционирования должен быть создан рабочий каталог.
Путь к нему нужно прописать здесь:
Packages—>Script—>Configure Script—>Current Working Directory
Заявку разработчикам на поддержку нового языка можно оставить здесь (отвечают быстро)

И немного юмора от разработчиков пакета Script,
у которых, судя по всему, спрашивают всё на свете:
How to run code in atom. Смотреть фото How to run code in atom. Смотреть картинку How to run code in atom. Картинка про How to run code in atom. Фото How to run code in atom
первод: Атом не может найти Нод | Руби | Питон | Мои носки

Python

Поддержка подсветки этого языка идёт изначально. Пакеты для работы с синтаксисом и отладки:
Linter + Language Python + Linter Python Pep8 + Script

Script запускает код на Python, а Linter и Linter Python Pep8 покажут синтаксические ошибки.
Возможно Вам, для работы с Python также поможет Atom Python Debugger.
Подсветка ошибок и запуск после установки будут выглядеть так:
How to run code in atom. Смотреть фото How to run code in atom. Смотреть картинку How to run code in atom. Картинка про How to run code in atom. Фото How to run code in atom

How to run code in atom. Смотреть фото How to run code in atom. Смотреть картинку How to run code in atom. Картинка про How to run code in atom. Фото How to run code in atom

How to run code in atom. Смотреть фото How to run code in atom. Смотреть картинку How to run code in atom. Картинка про How to run code in atom. Фото How to run code in atom

Swift

How to run code in atom. Смотреть фото How to run code in atom. Смотреть картинку How to run code in atom. Картинка про How to run code in atom. Фото How to run code in atom

Терминал

Для запуска исполняемого кода С, C++, Java иногда проще использовать сторонний пакет (не пакет Atom, а пакет вашего дистрибутива), который запускается через терминал, поскольку сам Atom поддерживает большое количество языков. Если Atom выступает в качестве редактора кода, a терминал рядом запускает его — это очень удобно для нас, поскольку терминал не имеет такое преимущество редактирования, как Atom.
Для запуска терминала в окне Atom установите пакет Term. Для запуска терминала в окне Atom выбрать
Packages—>Command Palette—>Toggle и Term
с нужными параметрами.

How to run code in atom. Смотреть фото How to run code in atom. Смотреть картинку How to run code in atom. Картинка про How to run code in atom. Фото How to run code in atom

В заключении ещё один интересный кликабельный анимационный gif от разработчиков script, ссылки.

How to run code in atom

Now that Atom is installed on your system, let’s fire it up, configure it and get acquainted with the editor.

When you launch Atom for the first time, you should get a screen that looks like this:

How to run code in atom. Смотреть фото How to run code in atom. Смотреть картинку How to run code in atom. Картинка про How to run code in atom. Фото How to run code in atom

This is the Atom welcome screen and gives you a pretty good starting point for how to get started with the editor.

Terminology

You can find definitions for all of the various terms that we use throughout the manual in our Glossary.

Command Palette

In that welcome screen, we are introduced to probably the most important command in Atom, the Command Palette. If you press Cmd+Shift+P Ctrl+Shift+P while focused in an editor pane, the command palette will pop up.

Throughout the book, we will use shortcut keybindings like Cmd+Shift+P Ctrl+Shift+P to demonstrate how to run a command. These are the default keybindings for the platform that we detected you running.

If you want to see a different platform than the one we detected, you may choose a different one by using the platform selector near the top of the page:

How to run code in atom. Смотреть фото How to run code in atom. Смотреть картинку How to run code in atom. Картинка про How to run code in atom. Фото How to run code in atom

If the Platform Selector is not present, then the current page doesn’t have any platform-specific content.

If you have customized your Atom keymap, you can always see the keybinding you have mapped in the Command Palette or the Keybindings tab in the Settings View.

This search-driven menu can do just about any major task that is possible in Atom. Instead of clicking around all the application menus to look for something, you can press Cmd+Shift+P Ctrl+Shift+P and search for the command.

How to run code in atom. Смотреть фото How to run code in atom. Смотреть картинку How to run code in atom. Картинка про How to run code in atom. Фото How to run code in atom

Not only can you see and quickly search through thousands of possible commands, but you can also see if there is a keybinding associated with it. This is great because it means you can guess your way to doing interesting things while also learning the shortcut key strokes for doing it.

For the rest of the book, we will try to be clear as to the text you can search for in the Command Palette in addition to the keybinding for different commands.

Settings and Preferences

Atom has a number of settings and preferences you can modify in the Settings View.

How to run code in atom. Смотреть фото How to run code in atom. Смотреть картинку How to run code in atom. Картинка про How to run code in atom. Фото How to run code in atom

This includes things like changing the theme, specifying how to handle wrapping, font settings, tab size, scroll speed and much more. You can also use this screen to install new packages and themes, which we’ll cover in Atom Packages.

To open the Settings View, you can:

Changing the Theme

The Settings View also lets you change the themes for Atom. Atom ships with 4 different UI themes, dark and light variants of the Atom and One theme, as well as 8 different syntax themes. You can modify the active theme by clicking on the Themes tab in the sidebar of the Settings View, or you can install new themes by clicking the Install tab.

How to run code in atom. Смотреть фото How to run code in atom. Смотреть картинку How to run code in atom. Картинка про How to run code in atom. Фото How to run code in atom

The UI themes control the style of UI elements like the tabs and the tree view, while the syntax themes control the syntax highlighting of text you load into the editor. To change the syntax or UI theme, simply pick something different in the appropriate dropdown list.

There are also dozens of themes on https://atom.io that you can choose from if you want something different. We will cover customizing a theme in Style Tweaks and creating your own theme in Creating a Theme.

Soft Wrap

You can use the Settings View to specify your whitespace and wrapping preferences.

How to run code in atom. Смотреть фото How to run code in atom. Смотреть картинку How to run code in atom. Картинка про How to run code in atom. Фото How to run code in atom

Enabling «Soft Tabs» will insert spaces instead of actual tab characters when you press the Tab key and the «Tab Length» setting specifies how many spaces to insert when you do so, or how many spaces are used to represent a tab if «Soft Tabs» is disabled.

The «Soft Wrap» option will wrap lines that are too long to fit in your current window. If soft wrapping is disabled, the lines will simply run off the side of the screen and you will have to scroll the window to see the rest of the content. If «Soft Wrap At Preferred Line Length» is toggled, the lines will wrap at 80 characters instead of the end of the screen. You can also change the default line length to a value other than 80 on this screen.

In Basic Customization we will see how to set different wrap preferences for different types of files (for example, if you want to wrap Markdown files but not other files).

Opening, Modifying, and Saving Files

Now that your editor is looking and acting how you want, let’s start opening up and editing files. This is a text editor after all, right?

Opening a File

There are several ways to open a file in Atom. You can do it by choosing File > Open from the menu bar or by pressing Cmd+O Ctrl+O to choose a file from the standard dialog.

How to run code in atom. Смотреть фото How to run code in atom. Смотреть картинку How to run code in atom. Картинка про How to run code in atom. Фото How to run code in atom

This is useful for opening a file that is not contained in the project you’re currently in (more on that next), or if you’re starting from a new window for some reason.

Another way to open a file in Atom is from the command line using the atom command. The Atom menu bar has a command named «Install Shell Commands» which installs the atom and apm commands if Atom wasn’t able to install them itself. The atom and apm commands are installed automatically as a part of Atom’s installation process.

You can run the atom command with one or more file paths to open up those files in Atom.

This is a great tool if you’re used to the terminal or you work from the terminal a lot. Just fire off atom [files] and you’re ready to start editing.
You can even open a file at a certain line (and optionally column) so the cursor will be positioned exactly where you want. For example, you may search some keyword in a repository to find the line you want to edit:

and then jump to the beginning of that line by appending a colon and the line number to the file path:

Sometimes you may want the cursor to jump to the exact column position of the searched keyword. Just append another colon plus the column number:

Editing and Saving a File

Editing a file is pretty straightforward. You can click around and scroll with your mouse and type to change the content. There is no special editing mode or key commands. If you prefer editors with modes or more complex key commands, you should take a look at the Atom package list. There are a lot of packages that emulate popular styles.

To save a file you can choose File > Save from the menu bar or Cmd+S Ctrl+S to save the file. If you choose File > Save As or press Cmd+Shift+S Ctrl+Shift+S then you can save the current content in your editor under a different file name. Finally, you can choose File > Save All or press Alt+Cmd+S to save all the open files in Atom.

Opening Directories

When you open Atom with one or more directories, you will automatically get a Tree View on the side of your window.

How to run code in atom. Смотреть фото How to run code in atom. Смотреть картинку How to run code in atom. Картинка про How to run code in atom. Фото How to run code in atom

The Tree View allows you to explore and modify the file and directory structure of your project. You can open, rename, delete and create new files from this view.

Atom Packages

Like many parts of Atom, the Tree View is not built directly into the editor, but is its own standalone package that is shipped with Atom by default. Packages that are bundled with Atom are referred to as Core packages. Ones that aren’t bundled with Atom are referred to as Community packages.

You can find the source code to the Tree View on GitHub at https://github.com/atom/tree-view.

This is one of the interesting things about Atom. Many of its core features are actually just packages implemented the same way you would implement any other functionality. This means that if you don’t like the Tree View for example, you could write your own implementation of that functionality and replace it entirely.

Opening a File in a Project

Once you have a project open in Atom, you can easily find and open any file within that project.

How to run code in atom. Смотреть фото How to run code in atom. Смотреть картинку How to run code in atom. Картинка про How to run code in atom. Фото How to run code in atom

Both core.ignoredNames and fuzzy-finder.ignoredNames are interpreted as glob patterns as implemented by the minimatch Node module.

Configuration Setting Notation

If you have a phrase you want to camel-case, follow these steps:

Running Python from Atom

In Sublime, we have an easy and convent way to run Python or almost any language for that matter using ⌘ + b (or ctrl + b )

Where the code will run in a small window below the source code and can easily be closed with the escape key when no longer needed.

Is there a way to replicate this functionally with Github’s atom editor?

6 Answers 6

Trending sort

Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.

It falls back to sorting by highest score if no posts are trending.

Switch to Trending sort

The script package does exactly what you’re looking for: https://atom.io/packages/script

The package’s documentation also contains the key mappings, which you can easily customize.

To execute the python command in atom use the below shortcuts:

For Windows/Linux, it’s SHIFT + Ctrl + B OR Ctrl + SHIFT + B

If you’re on Mac, press ⌘ + I

How to run code in atom. Смотреть фото How to run code in atom. Смотреть картинку How to run code in atom. Картинка про How to run code in atom. Фото How to run code in atom

To run the python file on mac.

Click on the install in the preferences to install packages.

Search for package «script» and click on install

How to run code in atom. Смотреть фото How to run code in atom. Смотреть картинку How to run code in atom. Картинка про How to run code in atom. Фото How to run code in atom

Yes, you can do it by:

— Install Python on your system. Atom requires the latest version of Python (currently 3.8.5). Note that Anaconda sometimes may not have this version, and depending on how you installed it, it may not have been added to the PATH. Install Python via https://www.python.org/ and make sure to check the option of «Add to PATH»

— Install «scripts» on Atom via «Install packages»

— Install any other autocomplete package like Kite on Atom if you want that feature.

I tried the normal way (I had Python installed via Anaconda) but Atom did not detect it & gave me an error when I tried to run Python. This is the way around it.

Источники информации:

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *