Atom Hydrogen: How is "run cell" used? - atom-editor

How is the "run cell" syntax in Hydrogen for Atom used? I placed multiple
# %%
tags throughout my code following the official manual here, but when I press Shift+Enter in between any two of the tags, it still only executes that line, not the entire cell block. I also tried the other syntax formats the manual describes, but none of them execute the whole cell.

A-C-enter hydrogen:run-cell
A-S-enter hydrogen:run-cell-and-move-down
https://github.com/nteract/hydrogen/issues/304

Related

Folding selected text

I like that in Atom text editor, you can hide code blocks to get a better overview. This is called Folding and is described here. There it says:
Finally, you can fold arbitrary sections of your code or text by making a selection and then typing Alt+Ctrl+F or choosing "Fold Selection" in the Command Palette.
I would like to make use of this, but it doesn't work for me. (I select a section of my code, then press the combination Alt+Ctrl+F, but nothing happens.) My operating system is Linux Mint 20.2 and the Atom version is 1.58.0.
I am looking for a fix or for a different method to fold selected text.
My use-case right now would be to fold Python docstrings. So if someone knows how to accomplish only that in Atom, you would also help me.
Although I did not find out why the hotkey doesn't work, I found a solution that fits my needs. The Atom package custom-folds adds the functionality to define regions that may be folded.
After installing custom-folds, I added the lines #<editor-folds and #</editor-fold> at the beginning and end of the docstring, respectively:
def average(a, b):
#<editor-fold
"""
Return the mean value of inputs a and b
"""
#</editor-fold>
return (a+b)/2
The commands #<editor-fold and #</editor-fold> are recognized and highlighted; also, a dropdown arrow appears where the code region can be folded or unfolded.

How to search previously executed commands in the Julia REPL?

Is there a quick way to search old commands which were run in the Julia REPL? Using the up arrow to go back in time seems to have a limit on its history and it is also quite cumbersome.
One of the five REPL models available in Julia is the "Search mode" which allows you to search through previously executed commands from the REPL. You can click "Control" + "r" to open search mode like is shown below:
(reverse-i-search)`':
There is also a forward search available with "Control" + "s". You can read more about Julia's REPL Search mode here: https://docs.julialang.org/en/v1/stdlib/REPL/#Search-modes
In addition to "real" search, you can also enter the beginning of a previous line and scroll up in the history (using ↑ or Ctrl-P) to switch between all previously entered lines starting with the same prefix.
So, if you had previously entered x = some_complicated_expression, you can write x = and go up until the line you were looking for appears.
Checkout: https://kristofferc.github.io/OhMyREPL.jl/latest/features/fzf/#Fuzzy-REPL-history-search
Which will be easier to use than reverse-i-search

Which keybind for smart-searching in history with ZSH?

When using the up and down arrow in my terminal (iTerm 2 on Mac OS Catalina), I can browse through my last commands using the up and down arrows.
I use ZSH (Oh-my-zsh to be precise) and if I type e.g. vim then press up, it will browse my history for any commands issued starting with vim.
I think it's annoying to have to move my hand to the arrow keys, so i wanted to bind ctrl-j and ctrl-k for browsing up and down.
I looked at bindkey and bound ^j to down-history and ^k to up-history. This allows me to browse my history, but not with the "smart" functionality (i'm not sure of the right terminology here) - It simply goes up and down in my history, without regards to my input.
I've looked through the standard widgets on the Zsh Line Editor manual, but I cannot find the right command for this.
Which command should I bind ^j and ^k to to get my desired result?
After some further digging, i ended up on the The Z-Shell Line Editor page at the section called "Prefix searching".
It revealed that the widget I was after, is called history-beginning-search-backward.
When using that widget, it works almost as I wanted it to, but not jumping to the end of the line.
A quick search lead me to another StackOverflow Question, that states that if you want to jump to the end of the line (as with the up arrow), it should be done as follows;
I had the same question and managed to find the solution with some experimentation.
I added the following to my .inputrc
"\eOA": history-search-backward # Up
"\eOB": history-search-forward # Down
"\C-P": "\eOA\C-E" # Ctrl-P
"\C-N": "\eOB\C-E" # Ctrl-N
This binds two hotkeys to Ctrl-P and Ctrl-N. One for history search, and the other Ctrl-E for end-of-line.

create multicursor in Atom

I use Atom on Ubuntu 17.10 with wayland window manager.
I can create multiple cursors with CTRL+Mousclick or with CTRL+d to select the next same string.
But how can I for example mark some lines and create a cursor at the start of each line?
Also would be great to use search and find-all to select lots of results in a text to create a cursor at all these results.
I used this workaround at the moment by selecting the line-break and use CTRL+d to select the next linebreaks too with extra cursors, then go one left and Pos1 to have the cursors at the start of each line.
I wanted to select a string that repeats about 200 times in a dataset of 3000 text-blocks in a bunch of output and then I wanted to expand the selection to each of those blocks. That would have been really easy with multiple cursors. I solved this another way now, but for the next time I would like to see a complete instruction manual about how to create multiple cursors in the standard atom setting. I couldn't find this. Search-engines give me lots of plugins and solutions in different multicursor plugins.
I found the manual that explains it like in sublime (ctrl alt up and down):
Alt+Shift+Up and Down
see: https://flight-manual.atom.io/using-atom/sections/editing-and-deleting-text/#multiple-cursors-and-selections
What is missing in the manual is also a useful option:
use "find all" with the search tool in Atom (CTRL+F)
press Alt + Enter to create cursors at all the found locations.
see: https://discuss.atom.io/t/how-do-i-create-multiple-cursors-from-search-result/53231/5
I wanted to make it easy so I could just use alt+⬇️ or alt+⬆️ to have multiple cursors. This was my solution and I think its the easiest:
# From Atom -> Keymap add the following lines:
'.editor':
'alt-up': 'editor:add-selection-above'
'alt-down': 'editor:add-selection-below'

How do I find out which syntax command causes a particular word to be highlighted in vim?

When I open a .c file in vim, and I type TODO inside a comment, it gets highlighted with yellow in vim. Note that this is not specified in my own .vimrc.
However, when I open a .r file, and I use TODO inside a comment, it does not get highlighted. I am trying to figure out how to make it so that TODO gets highlighted in R file as well, but I am not sure how to find the command that highlights TODO in .c files.
The default R syntax script ($VIMRUNTIME/syntax/r.vim) links rOKeyword, TODO's syntax group, to the Title highlight group.
The default C syntax script ($VIMRUNTIME/syntax/c.vim) links cTodo, TODO's syntax group, to the Todo highlight group.
TODO is not highlighted in R files as in C files because it is not linked to the right highlight group.
I suggest you contact the maintainer and ask him to fix that issue.
I wonder if this helps?
VIM: How can i know which highlight rule is being used for a keyword?
Examine the troubling highlight classes, do a grep or ack by the names in the .vim files under /syntax/ directories.

Resources