I see there is such command in the Edit menu tab, but is dim grey, both if I am inside a code tab and if I am outside it, as you can see in the attached screenshot.
How can I perform such operation?
UPDATE:
with the latest version of Jupyter lab (>1.1.4) this function is added!
Just click "Find", below the "Edit" menu: a contextual window will appear at the top right of the notebook.
There you click on the small arrow at the left side of the text field, and the "replace" function appear.
OLD ANSWER (still good anyway):
At the end, I found this solution, but it's only for those who know how to use VIM, the text editor.
I installed an extension, jupyterlab-vim, and so I can use VIM commands for search and replace text.
This appears to be an overkill as solution, but for VIM lovers (like me) using many VIM commands in Jupyter Lab is just fabulous.
A solution will be to:
sed -i "" 's/oldword/newword/g' mynotebook.ipynb
Found here: Is there a way to default to "Replace in all cells" in the "Find and Replace" in jupyter?
the shortcut for replacing all values in a cell is
Shift + Ctrl + H : Find and Replace all in current cell
You can access and set your own shortcuts via keyboard preferences or by Ctrl + M + H
Related
In notepad++, you can simply ctrl+h to find and replace, where first field asking what word, and second field asking what should it replace. Also, there's arrow up (previous) and arrow down (next).
That arrow button is useful because i can decide what line should i replace and what line shouldn't i replace, if i click arrow down button for example, it will select a word from previous line to next line. And if i click replace it will replace that line.
How do i do it in VIM?
I only find that arrow feature in search VIM feature with prefix /wordFind with click n for next and shift+n for previous, but i dont find such feature in :s/wordFind/replacerWord command
The simplest Vim equivalent would be the /c flag:
:%s/foo/bar/c
which allows you to accept or reject each substitution:
See :help :s_flags. It is limited to "Next", though.
Note that, if you use Gvim, you can get a modal window, like in Notepad++, with a "Next" button but no "Previous" button:
FWIW, the MacVim GUI's equivalent of that modal window actually has a "Previous" button, for some reason:
Note that those windows are more limited in functionality than the one in Notepad++. I guess they exist more as a courtesy to casual users than anything. The manual way is the real deal, in Vim and, from experience, it is much smoother and powerful.
I have a new installation of Visual Studio Code (default configuration, with vim keymap). I want to use the command "add selection to find next match". I think this is equivalent to how multicursors work in sublime text and vim (with an extension), or Atom (find and replace: select next).
When I try to run the command directly by using Ctrl D it does not work, taking me to the last line in the file. This might be some kind of conflict that might be easy to solve.
More interestingly, when I run the command from the command palette Ctrl Shift P.
The first time selects the word I am at (well done!)
The second time selects the next occurrence of that word, but loses the selection, moving the two cursors right after the two first occurrences of the word.
The third time and next times nothing happens, the selection was lost in the previous time.
How to get the awesome normal behaviour that other editors have?
PD: I have now confirmed that this behavior is not present without the vim keymap, may they be compatible somehow?
Ctl + D is a default Vim keybind that scrolls the window down in the buffer. This is expected behavior for the Vim extension, and you should disable the mapping if you wish to use it to run the VSCode command "Add Selection To Find Next Match".
To do this, open the extension's setting by clicking File > Preferences > Extensions. From there, choose the Vim extension and select the option to Configure Extension Settings. There will be an option called Handle Keys, where you can enter JSON data to send certain key combos back to VSCode (and there's another option to turn off all Ctl + Letter combos, called Use Ctrl Keys). You can find some examples of such data on the extension's Marketplace page. Below is the snippet of code that I added to my settings.json file to get Ctl + D back.
"vim.handleKeys": {
"<C-d>": false
}
From my testing, it looks like changing this setting also fixes the behavior when using the Command Palette. It might be a bug, but who cares when you are most likely just going to use Ctl + D anyway. :)
This is currently how I copy code from an editor to a search field in VS code using vscodevim.
Select text in editor somehow
Right click to open up the contextual menu (since pressing Ctrl+C does not seem to work on Ubuntu, even when in input mode, and 'p' does not work in the search field) and click copy
Press Ctrl+Shift+F to open the search field
Press Ctrl+V
I'm pretty sure this is not how copying from an editor to search field is intended to work. It it the steps 1 and 2 I would like to change to something better.
What is a more efficient and vim-like sequence?
If you want to search for the word under the cursor
Ctrl-F will do the trick.
Or you can use Vim's * command, which effectively does the same, but jumps to the next occurrence right away by default.
Otherwise
If you need to use the search field for whatever reason, then the standard Vim way to copy stuff to the clipboard works, so you can yank into the * or + registers. The steps will then be:
Select text
"+y (you can create a shortcut for this combination if you want)
Ctrl-Shift-F, Ctrl-V
See also: How to make vim paste from (and copy to) system's clipboard?.
Having said that, the more obvious approach might be to use Vim's built-in search features, so after selecting the text, the remaining steps would be y: (yanking selection to the default register and opening the command-line) then / or ? (search forward or backward), then <C-v> (pasting the yanked selection to the command-line - this works only in the VSCode plugin, while in Vim you should use <C-r>").
I'm new to VIM so there might be a better way using VIM commands but for now this works pretty well.
Go into insert mode with i than select the word you would like to search for (I'm using the mouse) and than just press ctrl + f. Your search window will open as usual containing the selected word in it.
Is there a command available to key mapping for toggling the display of invisibles in the Atom editor. A Show/Hide Invisibles command?
Where would I go to look for such a command?
YES
For Linux and Windows:
1) hit Ctrl+Shift+P and type keymap
2) select Application: open your keymap and add the following 2 lines to that file:
'body':
'shift-ctrl-i': 'window:toggle-invisibles'
Or any non-conflicting keystroke combination of your liking instead of shift-ctrl-i.
Note
For further detail, read documentation on CSON fromat (season) and atom-editor's implementaton of cson.
You can open the Command Palette (Cmd + Shift + P) and search for the Window: Toggle Invisibles command. Selecting that command should toggle invisibles on/off.
Here's what worked for me using the Mac version:
'.editor':
'ctrl-i': 'window:toggle-invisibles'
For Atom 1.58.0 on Mac, open Settings, Keybindings, and click on the 'your keymap file' link above the search box. Add the following two lines to the bottom of the file and save it:
'atom-text-editor':
'ctrl-i': 'window:toggle-invisibles'
Pressing Ctrl and i will then toggle on and off the invisible characters
Sometimes I have to write Java class where I need to define multiple fields of the same type. For example, I know that I will need to duplicate private final String on the next 4 lines.
Is it possible to spawn multiple carets in IntelliJ editor, so I can type on mutliple lines at the sime time?
IntelliJ IDEA 14.1 & 15
You can press Alt + Shift and using the mouse left click you can put many carets.
E.g.:
will become
typing "added" only once.
If you want to have a continuous vertical line, it's enough to press Alt + drag your mouse vertically. If there are lines with a length lower than the current position, the vertical line will be broken (carets will be placed at the end of every line) if "Allow placement of caret after end of line" is disabled (in File > Settings... > Editor > General > Virtual Space).
Another way to add a continuous vertical line is to hit Ctrl twice and then press up or down arrow key (supported in JetBrains 2016.X products, and possibly earlier).
If you cannot get the shortcuts working, check what they're currently assigned to under Settings > Keymap Add or Remove Caret, Clone Caret Above and Clone Caret Below. If they look right and you're on Linux, your window manager may be capturing the combination, e.g., for Alt + window drag operations.
See:
http://blog.jetbrains.com/idea/2015/02/multiple-selections-in-editor-using-mouse/
https://www.jetbrains.com/help/idea/2016.3/multicursor.html
I think "Column Selection Mode" could help you. You can enable it in the context menu in the editor. Then you can select multiple lines and type same text at once.
Column Select
For Windows, you can use CTRL+CTRL(Hold)+↑ / ↓. For Mac, replace the CTRL with ⌘.
Change Multi-caret Hotkey
To add a custom Keymap, CTRL+SHIFT+A, type keymap and click on the one with Settings as subtext. Search for Clone Caret Above and Clone Caret Below.
I mapped mine to ALT+SHIFT+↑ / ↓.
Bonus
Try holding combinations of CTRL, SHIFT, and arrows for improved selection power.
On Windows:
You can enable the Column Selection Mode (Alt + Shift + Insert)
And then Shift + ↑ / ↓ can select multiple columns
Hit Esc to go back to single cursor
Add/remove a caret: Alt + Shift + Mouse Click
Remove all carets: Esc
As for now(2018.9), you just:
Press middle mouse key to create a four-rows-high caret
Type what you want
Or,
Create the first line,
Press the "Duplicate entire line" key combination to create a new, identical line.
By the way, I think "multiple caret" should be like carets enabling me to edit different locations which are not necessarily vertically aligned. In Sublime Text you can press Ctrl and click. And in IntelliJ you can only "Clone caret up/down", that is to say, they are vertically aligned, which is not flexible.