Move cursor multiple lines in Atom - atom-editor

I'm looking for a keybinding that will move the cursor x number of lines up or down in Atom, a la Vim.
I've looked around but can only find cmd+up and cmd+down, which move the cursor to the top or bottom of the file respectively.

You can use the go-to-line package. Default keyboard shortcut is CTRL+G. Install it via the terminal with
$ apm install go-to-line
or download it through Settings.

Related

Change R assignment operators to red complete arrows in VSCode?

I am new to VSCode and trying to use R in VSCode.
I was wondering how to change R assignment operators to the red ones(arrows) as showed in the VSCode website.
Here is the website:
https://code.visualstudio.com/docs/languages/r#_code-completion-intellisense
You need to have a font with ligatures. One of the most common to use is FiraCode. To install it, check here.
Then, in VSCode, go to settings.json and paste the following lines (check the full instructions here.
"editor.fontFamily": "Fira Code",
"editor.fontLigatures": true
After that, close/reopen VSCode, and it should work.

automatically set `options("width")` to current vscode terminal width based on a DOM attribute?

If I open a vscode integrated terminal, I can do:
$ R
> options("width"=200) # print stuff as wide as i want
So I'm wondering if there is any way to automatically re-run a command like options("width"=<current terminal size>) based on some DOM attribute whenever I resize the vscode terminal?
Unfortunately, there is no easy way to make vanilla R terminal to auto-adjust to vscode R terminal. I recommend that you use radian which support auto-adjusting width.

How to open specific file from atom?

How do i open a specific file from atom. I have in laravel master.blade.php and I want to put shortcut CTRL-1 for example and open it.I use now advanced-open-file but I want something faster because I all the time name some files the same. Is there a plugin for that ?
1. Add command
Add the following to your init.coffee (File > Init Script…)
atom.commands.add 'atom-text-editor',
'open:master-blade': (event) ->
atom.workspace.open('path/to/master.blade.php')
See available options for atom.workspace.open
2. Add shortcut
Now add the following to keymap.cson (File > Keymap…)
'.editor:not(.mini)':
'ctrl+1': 'open:master-blade'
Note: You can use Atom's built-in keybinding-resolver to make sure the shortcut isn't used by one of your installed packages.
It is very simple. In Ubuntu you can do this things following below steps...
Open the terminal.
Go to the folder of your project.
Enter command atom ./<path_of_the_file>
If you want to open whole project then enter atom .
Atom will open that file.

Atom editor - convert line endings to UNIX

I need to convert the line endings of some mock data into Unix format. I'm using Atom editor on Win 7.
Looking online, I found an Atom package to convert line endings, but the package said it is deprecated since Atom now has this as a standard feature.
I cannot find any such standard feature in Atom - and Atom's documentation doesn't even know what line-ending conversion is.
'About Atom' tells me Atom is up-to-date with v.1.23.3
This, to me, seems a paradox.
(And no, I cannot just use Notepad++.)
I've looked around at a lot of solutions, but have not found one that will actually work.
The built in line-ending-selector package supports this use case: https://atom.io/packages/line-ending-selector
The package's documentation describes how to do this:
You can click the line ending in the status-bar to open a modal with the line ending options. Selecting a different line ending will change each line of the file in the active editor.
If you prefer to use the keyboard, you can also open the command palette (cmd-shift-p on macOS), type Convert and then use the Line Ending Selector: Convert to LF and Line Ending Selector: Convert to CRLF commands from there.
Go to Preferences under Atom menu. Uner the settings window, go to Packages. In packages search on line-ending-selector. This reveals a core package that is loaded with Atom. Scroll down the line-ending-selector page and you see the header Settings. Below that you can choose the default line endings. You can choose LF, CNTL-LF, or OS. Set this to the value you want.

Atom/Sublime like Multiple selections in Jupyter

How can I select matching keywords in a Jupyter notebook via a keyboard shortcut? For example, in the Atom/Sublime editor I can hit cmd + D on a mac (or Ctrl + d on Windows) while the cursor is over 'var' and each time I do that the next 'var' will be highlighted. I can then type the new variable name and 'var' is replaced with whatever I typed.
var = "hello"
print(var)
print(var)
Is there an equivalent in a Jupyter notebook?
Add custom.js to
C:\Users\username\.jupyter\custom # for Windows and
~/.jupyter/custom/ # for Mac
with content
require(["codemirror/keymap/sublime", "notebook/js/cell", "base/js/namespace"],
function(sublime_keymap, cell, IPython) {
cell.Cell.options_default.cm_config.keyMap = 'sublime';
cell.Cell.options_default.cm_config.extraKeys["Ctrl-Enter"] = function(cm) {}
var cells = IPython.notebook.get_cells();
for(var cl=0; cl< cells.length ; cl++){
cells[cl].code_mirror.setOption('keyMap', 'sublime');
cells[cl].code_mirror.setOption("extraKeys", {
"Ctrl-Enter": function(cm) {}
});
}
}
);
and restart jupyter. Now Ctrl+D should work like it does in Sublime.
You can see that Ctrl-Enter functionality is disabled as it would be very convenient to run current cell rather than creating new line for most users. You can choose to have that functionality by commenting that line out.
You can disable other key config that you don't want in a similar way.
Most recent (and easy) way
The best way right now to achieve Sublime-like keymapping in Jupyter Notebook: Select CodeMirror Keymap from jupyter-contrib-nbextensions. As reported in the homepage:
The jupyter_contrib_nbextensions package contains a collection of community-contributed unofficial extensions that add functionality to the Jupyter notebook.
I personally use several extensions from this package and I find them very useful.
As reported in the installation docs, you simply need to run:
pip install jupyter_contrib_nbextensions
to install the extensions (or better, I would suggest:
python -m pip install jupyter_contrib_nbextensions
where python points to the python executable of the installation you are using within Jupyter Notebook). You can also use conda if you prefer.
Anyway, you then need to copy some JS and CSS stuff to make the extensions work within Jupyter Notebook, which you can achieve through:
jupyter contrib nbextension install --user
again, assuming that jupyter points to the jupyter executable you are using to run your notebooks.
At this point, you simply need to enable the extension: navigate the nbextensions_configurator (that comes as a dependency with the jupyter_contrib_nbextensions package), which you can easily do through the Jupyter Notebook dashboard (to be clear, the page you open to run your notebooks) by browsing the Nbextensions tab and check the box corresponding to Select CodeMirror Keymap.
Done! Launching a notebook it will be sufficient to click on Edit>Keymaps>Sublime to achieve the desired behaviour.
I know this is a rather old question, but I happened to come across it before finding out about jupyter_contrib_nbextensions (and in particular the Select CodeMirror Keymap extension). Thus, I decided to post this answer, hopefully to help other people like me and to let them avoid some further search or messing up with customized JS files (which could scary someone).
In jupyter lab now you can add in the extension by searching sublime
Click install and rebuild jupyter.
**Notice: when you click install look at the terminal console, the building result will be shown there
The above solution worked for me, but I found that it had the undesirable effect of entering a "tab" character when I hit enter. Here is the associated GitHub issue: https://github.com/jupyter/notebook/issues/4769#issuecomment-511935127
Per that post, I found that this solution gives the right ctrl + d behavior, and keeps tabs-as-spaces.
require(["codemirror/keymap/sublime", "notebook/js/cell", "base/js/namespace"],
function(sublime_keymap, cell, IPython) {
// setTimeout(function(){ // uncomment line to fake race-condition
cell.Cell.options_default.cm_config.keyMap = 'sublime';
var cells = IPython.notebook.get_cells();
for(var c=0; c< cells.length ; c++){
cells[c].code_mirror.setOption('keyMap', 'sublime');
}
// }, 1000)// uncomment line to fake race condition
}
);
In Jupyter Lab, this can now be set in Settings > Text Editor Key Map > Sublime Text.
The only solution which made this work for me is
pip install jupyterlab_sublime

Resources