Как в repl it отменить действие

от admin

Working with shortcuts

Be more productive with Replit by learning the code editor’s powerful shortcuts for editing, writing, and inspecting code.

The shortcuts we'll show you here are for Windows. If you're using a Mac, use the Cmd key instead of the Ctrl key, and the Option key instead of the Alt key.

When you use a shortcut, be sure that your repl window has been clicked, or these shortcuts may access the browser's keyboard shortcuts.

Basic editing​

Command Key
Select up Shift+Up
Select down Shift+Down
Select line Ctrl+L
Cut line (without selection) Ctrl+X
Copy line (without selection) Ctrl+C
Paste Ctrl+V
Delete line Ctrl+Shift+K
Move Line Down Alt+Down
Move Line Up Alt+Up
Copy Line Down Shift+Alt+Down
Copy Line Down Shift+Alt+Up
Undo Ctrl+Z
Redo Ctrl+Y
Format Ctrl+S
Add cursors Alt+Left Click
Undo last cursor operation Ctrl+U
Select all occurrences of current selection Ctrl+Shift+L
Select all occurrences of current word Ctrl+F2
Jump to matching bracket Ctrl+Shift+\
Indent Line Ctrl+]
Outdent Line Ctrl+[
Go to Beginning of Line Home
Go to End of Line End
Go to End of File Ctrl+End
Go to Beginning of File Ctrl+Home
Toggle Line Comment Ctrl+/
Add Block Comment Shift+Alt+A
Find Ctrl+F
Find Next Enter
Find Previous Shift+Enter
Add Selection To Next Find Match Ctrl+D
Select All Occurrences of Find Match Alt+Enter
Trigger Suggest Ctrl+Space
Go to References ctrl+F12
Peek Definition shift+F12
Rename Symbol F2
Generate Code (Ghostwriter subscription required) Alt+G

Navigation​

Command Key
Go to Line. Ctrl+G
Go to File. Quick Open Ctrl+P
Go to Next Error or Warning F8
Show command palette Ctrl+Shift+P or F1 (use F1 on Firefox).
Go Back Alt+Left
Go Forward Alt+Right
Show Version Control Ctrl+Shift+G
Show Search Ctrl+Shift+F
Open Settings Ctrl+,

Frequently used keyboard shortcuts​

The following keyboard shortcuts can be used in a variety of ways. If you forget a keyboard shortcut, check the command palette.

Command palette​

The command palette allows you to view all available commands based on your current context.

To access the command palette, press F1 or Ctrl+Shift+P .

Note: If you are using Firefox, Ctrl+Shift+P will open an incognito window, so use the F1 option instead.

Moving the current line​

Press Alt+Up or Alt+Down to move the current line up or down.

Clone the current line​

Press Shift+Alt+Up or Shift+Alt+Down to clone the current line above or below.

Selecting lines​

Press Ctrl+L to select a line.

Deleting lines​

Press Ctrl+Shift+K to delete a line.

Adding cursors​

Press Alt+Left Click to add more cursors.

Press Ctrl+F to find.

Adding selections to next find match​

Press Ctrl+D to select and then Ctrl+F to add a selection to the next find match.

Navigation​

Use the following shortcuts to navigate the editor.

Open files​

Press Ctrl+P to quickly open files.

Go to line​

Press Ctrl+G to go to a specified line.

Navigating with Tab key​

In most cases, you can navigate the entire page via the Tab key. In the editor, console, and shell, however, Tab will be used for indentation. In these cases, you can press Esc and then press Tab to navigate to the next element on the page.

Как в repl it отменить действие

Replit — популярная бесплатная онлайн-IDE, требующая совсем небольшой настройки перед созданием проектов. Этот редактор поддерживает больше 50 языков и используется на многих курсах по программированию.

В этой статье я расскажу, как начать работать в Replit, и познакомлю вас с его базовыми функциями.

Как создать аккаунт в Replit

Для начала заходим на домашнюю страницу Replit. В правом верхнем углу кликните Sign Up. Для регистрации на сайте можно ввести username, email и пароль, а можно воспользоваться аккаунтом в Google, Facebook или GitHub.

Войдя, вы попадете на домашнюю страницу своего аккаунта.

Что такое Repl и как его создать?

Repl расшифровывается как «read-eval-print loop». Это интерактивная среда программирования, в которой создавать маленькие проекты.

В Replit есть три способа создания нового repl.

Первый — кликнуть кнопку Create Repl в верхнем левом углу домашней страницы.

Также можно кликнуть значок «+» под разделом Create.

Третий вариант — кликнуть «+» в верхнем правом углу.

После этого вы сможете выбрать один из множества шаблонов Replit, включая Python, Node, Java, HTML & CSS, Ruby и многие другие.

Выбрав язык, выберите имя для своего проекта.

В бесплатной версии Replit нельзя создавать приватные проекты. Если вам нужен приватный repl, придется заплатить за Pro-версию.

Выбрав имя, нажмите голубую кнопку Create Repl.

После этого вы должны переместиться в редактор.

Базовые функции редактора Replit

В этом разделе мы пройдемся по базовым функциям, которыми вы можете воспользоваться в редакторе Replit. Сюда входит отладчик, файлы и папки, контроль версий, юнит-тесты и т. п.

Файлы и папки

Чтобы добавить в проект файлы и папки, можно кликнуть на иконку файла в верхнем левом углу.

Для добавления файла кликните иконку Add file. Рядом с ней есть иконка Add folder — для создания папок.

Если хотите загрузить файлы или папки со своего компьютера, нажмите иконку с тремя точками.

Для удаления файлов или папок нажмите иконку с тремя точками, расположенную рядом с файлом, который хотите удалить. Откроется список опций.

Контроль версий в Replit

Вы также можете подключиться к своему GitHub-аккаунту и создать репозиторий для этого проекта. На момент написания этой статьи эта функция все еще в бете.

Сначала нажмите на значок контроля версий с левой стороны страницы редактора. Вы увидите возможность для подключения к GitHub-аккаунту.

Вам будет предложено разрешить Replit создавать новые репозитории на GitHub.

Введите ваши данные для входа на GitHub.

Если вы подключили несколько GitHub-аккаунтов, выберите тот, куда хотите установить Replit.

Затем нужно будет авторизоваться в Replit для установки.

После установки и авторизации вы будете перенаправлены обратно в редактор Replit.

Теперь все изменения будут отслеживаться и вы сможете пушить их на GitHub. Напишите короткое сообщение коммита и кликните кнопку Commit & push.

Все свои сообщения коммитов вы сможете видеть в панели контроля версий.

Нажмите кнопку Connect to GitHub, чтобы создать новый репозиторий.

Вы можете добавить описание репозитория, а затем нажать кнопку Create GitHub repository.

Когда репозиторий будет создан, вы увидите его имя в панели контроля версий.

Он также будет виден на GitHub.

Отладчик

В редакторе Replit есть инструмент отладки. С его помощью можно проходить свой код строчка за строчкой, отслеживать, что происходит, и исправлять ошибки.

Эта функция тоже пока в бете. Найти ее можно с левой стороны страницы редактора.

Установка пакетов в Replit

Вы можете устанавливать различные пакеты в свои проекты, например, morgan, express или cors. Для этого воспользуйтесь панелью Packages в левой части страницы редактора.

Найдите пакет, который хотите установить, и нажмите значок «+».

В правой стороне экрана расположена консоль. В ней вы можете увидеть, что пакет устанавливается.

Secrets (переменные окружения)

Replit больше не поддерживает создание .env-файлов.

Вместо этого вам придется использовать вкладку Secrets, где вы сможете хранить ваши переменные окружения. Иконка Secrets находится в левой части страницы редактора.

В поле ввода Key нужно вписать имя своего ключа, а в поле value — его значение. Затем нажмите Add new secret.

После этого вы увидите новосозданную переменную окружения во вкладке Secrets.

Если вам потребуется отредактировать переменную, просто наведите мышь на ее имя и нажмите значок карандаша.

Теперь вы можете использовать эту переменную окружения в своем коде.

Кастомизация Replit

Если вы хотите настроить редактор для своего проекта, нажмите на значок-шестеренку в левой части страницы редактора.

База данных Replit

Если хотите использовать хранилище Replit для ключей и значений, нажмите значок Database в левой части страницы редактора.

Узнать больше об использовании Replit Database можно в документации.

Как добавить в Replit юнит-тесты

Если вы хотите добавить в свой проект юнит-тесты, кликните соответствующий значок («галочку») в левой части страницы редактора.

Затем нажмите кнопку Add test.

После этого вы сможете создать тесты, введя имя, код и сообщение о провале теста. Сохраните введенные данные.

Скриншот, показывающий юнит-тест для сложения двух чисел:

После этого нажмите кнопку Run tests.

Запущенные тесты и результат вы увидите в консоли.

Как использовать кнопку Run в Replit

Если вы хотите запустить сервер для своего проекта, кликните на зеленую кнопку Run вверху страницы редактора.

Нажав кнопку, вы увидите результат работы своего кода в окне предпросмотра и консоли в правой части страницы редактора.

Как очистить консоль в Replit

Чтобы очистить консоль, нажмите крестик в углу окна консоли.

Что собой представляет консоль Shell?

Если вам нужно вводить команды, например, для удаления или добавления папок, вы можете воспользоваться консолью оболочки.

Как добавить в Replit кастомный домен?

В превью можно добавить кастомный домен для своего проекта. Для этого нажмите на иконку карандаша рядом с URL превью.

После этого можно будет добавить ваш домен и информацию CNAME:

Как опубликовать проект в Replit?

Завершив работу над проектом, вы сможете его опубликовать и поместить в коллекцию Replit Apps.

Для начала кликните на имя проекта в верхнем левом углу.

Вы сможете добавить короткое описание проекта и нажать кнопку Publish.

После этого можно будет вставить описание, добавить обложку и теги. Когда закончите, нажмите кнопку публикации.

Если захотите опубликовать обновление, опять же кликните на своем проекте, а затем — Publish update.

Допустим, вы хотите изменить статус проекта и убрать его из опубликованных. Нажмите иконку с тремя точками в правом углу страницы публикации и выберите опцию Unpublish.

Как поделиться ссылкой на проект на Replit

Если вы хотите расшарить URL проекта, сперва нужно кликнуть зеленую кнопку Run, а затем — иконку Open in new tab.

Ваша страница откроется в новой вкладке.

Если хотите поделиться URL, ведущий на редактор и окно предпросмотра, просто используйте ссылку в адресной строке браузера.

Перейдя по ссылке, вы увидите это:

Делиться этой ссылкой имеет смысл, если вам нужна помощь в работе над проектом ы вы хотите показать другим разработчикам свой код и файлы. Пока вы не поделитесь своим проектом, другие люди не увидят ваших переменных окружения.

Как пригласить других людей редактировать ваши repl

В Replit есть специальная функция, позволяющая пригласить в проект других разработчиков.

Нажмите кнопку Invite в правом верхнем углу страницы редактора.

В поле поиска можно добавить пользователей Replit или email-адреса людей, которых вы хотите пригласить.

Затем нажмите синюю кнопку Invite.

Вы увидите приглашение в ожидающих подтверждения.

Также можно послать специальную ссылку пользователю, которого хотите пригласить в проект. Кликните кнопку Generate a join link.

Если захотите удалить кого-то из приглашенных, нажмите крестик рядом с его именем.

Что дает платная подписка на Replit?

Тарифный план Hacker предполагает больше памяти и места, более высокую скорость и приватные repl.

План Teams предназначен для студентов и учителей, совместно работающих над учебными проектами.

Как в repl it отменить действие

«The answer to life the universe and everything is 32»

‘The answer to life the universe and everything is 32’

> “The answer to life the universe and everything is 32”

‘The answer to life the universe and everything is 42’

‘The answer to life the universe and everything is 42’

> Math.
Math.__defineGetter__ Math.__defineSetter__ Math.__lookupGetter__
Math.__lookupSetter__ Math.__proto__ Math.constructor
Math.hasOwnProperty Math.isPrototypeOf Math.propertyIsEnumerable
Math.toLocaleString Math.toString Math.valueOf
Math.E Math.LN10 Math.LN2
Math.LOG10E Math.LOG2E Math.PI
Math.SQRT1_2 Math.SQRT2 Math.abs
Math.acos Math.acosh Math.asin
Math.asinh Math.atan Math.atan2
Math.atanh Math.cbrt Math.ceil
Math.clz32 Math.cos Math.cosh
Math.exp Math.expm1 Math.floor
Math.fround Math.hypot Math.imul
Math.log Math.log10 Math.log1p
Math.log2 Math.max Math.min
Math.pow Math.random Math.round
Math.sign Math.sin Math.sinh
Math.sqrt Math.tan Math.tanh
Math.trunc

4: Использование команд REPL

.break Sometimes you get stuck, this gets you out
.clear Alias for .break
.editor Enter editor mode
.exit Exit the repl
.help Print this help message
.load Load JS from a file into the REPL session
.save Save all evaluated commands in this REPL session to a file
Press ^C to abort current expression, ^D to exit the repl

Как в repl it отменить действие

Как в repl it отменить действие

Be more productive with Replit by learning the code editor’s powerful shortcuts for editing, writing, and inspecting code.

The shortcuts we’ll show you here are for Windows. If you’re using a Mac, use the Cmd key instead of the Ctrl key, and the Option key instead of the Alt key.

When you use a shortcut, be sure that your repl window has been clicked, or these shortcuts may access the browser’s keyboard shortcuts.

Basic editing​
Command Key
Select up Shift+Up
Select down Shift+Down
Select line Ctrl+L
Cut line (without selection) Ctrl+X
Copy line (without selection) Ctrl+C
Paste Ctrl+V
Delete line Ctrl+Shift+K
Move Line Down Alt+Down
Move Line Up Alt+Up
Copy Line Down Shift+Alt+Down
Copy Line Down Shift+Alt+Up
Undo Ctrl+Z
Redo Ctrl+Y
Add cursors Alt+Left Click
Undo last cursor operation Ctrl+U
Select all occurrences of current selection Ctrl+Shift+L
Select all occurrences of current word Ctrl+F2
Jump to matching bracket Ctrl+Shift+\
Indent Line Ctrl+]
Outdent Line Ctrl+[
Go to Beginning of Line Home
Go to End of Line End
Go to End of File Ctrl+End
Go to Beginning of File Ctrl+Home
Scroll Line Down Ctrl+Down
Scroll Line Up Ctrl+Up
Collapse region Ctrl+Shift+[
Uncollapse region Ctrl+Shift+]
Collapse all regions Ctrl+K Ctrl+0
Uncollapse all regions Ctrl+K Ctrl+J
Add Line Comment Ctrl+K Ctrl+C
Remove Line Comment Ctrl+K Ctrl+U
Toggle Line Comment Ctrl+/
Add Block Comment Shift+Alt+A
Find Ctrl+F
Replace Ctrl+H
Find Next Enter
Find Previous Shift+Enter
Add Selection To Next Find Match Ctrl+D
Select All Occurrences of Find Match Alt+Enter
Trigger Suggest Ctrl+Space
Go to References ctrl+F12
Peek Definition shift+F12
Rename Symbol F2
Navigation​
Command Key
Go to Line. Ctrl+G
Go to File. Quick Open Ctrl+P
Show Problems/invite link Ctrl+Shift+M
Go to Next Error or Warning F8
Show command palette Ctrl+Shift+P or F1 (use F1 on Firefox).
Go Back Alt+Left
Go Forward Alt+Right
Show Version Control Ctrl+Shift+G
Show Search Ctrl+Shift+F
Open Settings Ctrl+,
Frequently used keyboard shortcuts​

The following keyboard shortcuts can be used in a variety of ways. If you forget a keyboard shortcut, check the command palette.

Command palette​

The command palette allows you to view all available commands based on your current context.

To access the command palette, press F1 or Ctrl+Shift+P .

Note: If you are using Firefox, Ctrl+Shift+P will open an incognito window, so use the F1 option instead.

Moving the current line​

Press Alt+Up or Alt+Down to move the current line up or down.

Clone the current line​

Press Shift+Alt+Up or Shift+Alt+Down to clone the current line above or below.

Selecting lines​

Press Ctrl+L to select a line.

Deleting lines​

Press Ctrl+Shift+K to delete a line.

Adding cursors​

Press Alt+Left Click to add more cursors.

Press Ctrl+F to find.

Replace​

Press Ctrl+H to replace.

Adding selections to next find match​

Press Ctrl+D to select and then Ctrl+F to add a selection to the next find match.

Отменить выход REPL

Я ищу способ переопределить и проанализировать весь вывод в REPL Python: например, python / IPython в терминале, qtconsole.

Это просто для печатного текста, переопределив функцию печати. В качестве тривиального примера предположим, что мы хотели бы добавить восклицательный знак ко всему выводу:

Теперь все команды печати будут иметь добавленный восклицательный знак. Это можно сбросить с помощью:

Мой вопрос: как мне сделать эквивалент для вывода REPL? Например, как мне сделать так, чтобы это работало?

Поиски привели меня по пути contextlib, subprocess и sys.stdout, но я еще не нашел решения. Безуспешно исследовали модуль печати sympy на Github.

2 ответа

Я просто попытался перезаписать sys.stdout.write , и это сработало (с некоторыми причудами). Кто-то поправит меня, если я ошибаюсь, но я думаю, что лучше этого не будет.

РЕДАКТИРОВАТЬ:
Я зашел так далеко. Не поняла, откуда взялся этот 1 лишний ! .

Пример, который работает в IPython QtConsole на основе эту статью. Это используется вместе с решением Orangeink, переопределяющим стандартный вывод:

Как в repl it отменить действие

«The answer to life the universe and everything is 32»

‘The answer to life the universe and everything is 32’

> “The answer to life the universe and everything is 32”

‘The answer to life the universe and everything is 42’

‘The answer to life the universe and everything is 42’

> Math.
Math.__defineGetter__ Math.__defineSetter__ Math.__lookupGetter__
Math.__lookupSetter__ Math.__proto__ Math.constructor
Math.hasOwnProperty Math.isPrototypeOf Math.propertyIsEnumerable
Math.toLocaleString Math.toString Math.valueOf
Math.E Math.LN10 Math.LN2
Math.LOG10E Math.LOG2E Math.PI
Math.SQRT1_2 Math.SQRT2 Math.abs
Math.acos Math.acosh Math.asin
Math.asinh Math.atan Math.atan2
Math.atanh Math.cbrt Math.ceil
Math.clz32 Math.cos Math.cosh
Math.exp Math.expm1 Math.floor
Math.fround Math.hypot Math.imul
Math.log Math.log10 Math.log1p
Math.log2 Math.max Math.min
Math.pow Math.random Math.round
Math.sign Math.sin Math.sinh
Math.sqrt Math.tan Math.tanh
Math.trunc

4: Использование команд REPL

.break Sometimes you get stuck, this gets you out
.clear Alias for .break
.editor Enter editor mode
.exit Exit the repl
.help Print this help message
.load Load JS from a file into the REPL session
.save Save all evaluated commands in this REPL session to a file
Press ^C to abort current expression, ^D to exit the repl

Как в repl it отменить действие

Как в repl it отменить действие

Be more productive with Replit by learning the code editor’s powerful shortcuts for editing, writing, and inspecting code.

The shortcuts we’ll show you here are for Windows. If you’re using a Mac, use the Cmd key instead of the Ctrl key, and the Option key instead of the Alt key.

When you use a shortcut, be sure that your repl window has been clicked, or these shortcuts may access the browser’s keyboard shortcuts.

Basic editing​
Command Key
Select up Shift+Up
Select down Shift+Down
Select line Ctrl+L
Cut line (without selection) Ctrl+X
Copy line (without selection) Ctrl+C
Paste Ctrl+V
Delete line Ctrl+Shift+K
Move Line Down Alt+Down
Move Line Up Alt+Up
Copy Line Down Shift+Alt+Down
Copy Line Down Shift+Alt+Up
Undo Ctrl+Z
Redo Ctrl+Y
Add cursors Alt+Left Click
Undo last cursor operation Ctrl+U
Select all occurrences of current selection Ctrl+Shift+L
Select all occurrences of current word Ctrl+F2
Jump to matching bracket Ctrl+Shift+\
Indent Line Ctrl+]
Outdent Line Ctrl+[
Go to Beginning of Line Home
Go to End of Line End
Go to End of File Ctrl+End
Go to Beginning of File Ctrl+Home
Scroll Line Down Ctrl+Down
Scroll Line Up Ctrl+Up
Collapse region Ctrl+Shift+[
Uncollapse region Ctrl+Shift+]
Collapse all regions Ctrl+K Ctrl+0
Uncollapse all regions Ctrl+K Ctrl+J
Add Line Comment Ctrl+K Ctrl+C
Remove Line Comment Ctrl+K Ctrl+U
Toggle Line Comment Ctrl+/
Add Block Comment Shift+Alt+A
Find Ctrl+F
Replace Ctrl+H
Find Next Enter
Find Previous Shift+Enter
Add Selection To Next Find Match Ctrl+D
Select All Occurrences of Find Match Alt+Enter
Trigger Suggest Ctrl+Space
Go to References ctrl+F12
Peek Definition shift+F12
Rename Symbol F2
Navigation​
Command Key
Go to Line. Ctrl+G
Go to File. Quick Open Ctrl+P
Show Problems/invite link Ctrl+Shift+M
Go to Next Error or Warning F8
Show command palette Ctrl+Shift+P or F1 (use F1 on Firefox).
Go Back Alt+Left
Go Forward Alt+Right
Show Version Control Ctrl+Shift+G
Show Search Ctrl+Shift+F
Open Settings Ctrl+,
Frequently used keyboard shortcuts​

The following keyboard shortcuts can be used in a variety of ways. If you forget a keyboard shortcut, check the command palette.

Command palette​

The command palette allows you to view all available commands based on your current context.

To access the command palette, press F1 or Ctrl+Shift+P .

Note: If you are using Firefox, Ctrl+Shift+P will open an incognito window, so use the F1 option instead.

Moving the current line​

Press Alt+Up or Alt+Down to move the current line up or down.

Clone the current line​

Press Shift+Alt+Up or Shift+Alt+Down to clone the current line above or below.

Selecting lines​

Press Ctrl+L to select a line.

Deleting lines​

Press Ctrl+Shift+K to delete a line.

Adding cursors​

Press Alt+Left Click to add more cursors.

Press Ctrl+F to find.

Replace​

Press Ctrl+H to replace.

Adding selections to next find match​

Press Ctrl+D to select and then Ctrl+F to add a selection to the next find match.

Читать:
Как сделать горизонтальный скролл в тильде

Похожие статьи