IPython Notebook keyboard shortcut search for text - replace

Is there a keyboard shortcut to search for text in an IPython Notebook?
I looked under Help | Keyboard shortcuts and there are lots of cool shortcuts but none for searching for text?
The notebook is running in FireFox on Ubuntu.

There is a find-and-replace command in Jupyter. It's key binding is F (command mode):
Of course you can find text with the browser's functionality, (I find it sometimes better), but the command in Jupyter is also very useful. I use a lot that function Replace in selected cells when I copy-paste a bunch of code and then change variables or something like that:
(Note: You can launch the Command Palette with shift+ctrl+P, and browse or run other commands)

Enter Command Mode by pressing esc, followed by find and replace key binding f, so
esc then f
Take the User Interface Tour (Help Menu) if you haven't already

As of Jupyter Lab v1.0.2 the CTRL+F twice press trick described in my comment above doesn't seem to work anymore.
I found the internal search functionality of jupyter lab pretty annoying, since it only searches in the current cell. I wanted to directly access the native browser search with CTRL+F.
To disable jupyter lab search function (and use browser search instead):
open Settings\Advanced Settings Editor
add the following to User Preferencec:
{
"shortcuts": [
{
"command": "documentsearch:start",
"keys": [
"Accel F"
],
"selector": ".jp-mod-searchable",
"disabled": true
}
]
}
This will override the System Default, with "disabled": true added, and enables Browser CTRL+F in all Jupyter Lab instances.

Select the cell(s) in which you want to replace.
Then just click outside those cells
Press f.
You are done!

:Embarassed: "Running in" means use the browser "find text on this page" shortcut.
Firefox shortcut for this is ctrl - F.

Related

Navigate to the file from output in the terminal - WebStorm

Is it possible to tune WebStorm so that when I have something like this in my terminal window, then I just click on the filename and jump to it.
Not possible using built-in terminal (please vote for IDEA-118566 and IDEA-154439).
Awesome Console plugin might be a solution; but it doesn't support built-in terminal (https://github.com/anthraxx/intellij-awesome-console/issues/23)
there is also Output Link Filter plugin that provides similar functionality, but it looks outdated and (also) doesn't work in built-in terminal
Update (2022): IDEA-118566 is already fixed, links should work. Please note that providing links for particular output needs adding specific logic handing such output. Thus, if you encounter missing links in a particular output, please file a separate issue request describing link output format and steps to reproduce such output.
Webstorm does in fact now have this functionality.
Note that the bug about this functionality being missing (linked in another answer) has been marked as fixed: https://youtrack.jetbrains.com/issue/IDEA-118566.
It's not quite a single click solution, but what I do, is double click the text so that it auto selects and copies the path, including line and char numbers to clipboard. Then use the shortcut for Goto File.... Hit paste (cmd+v) then Enter and it will take you to the exact location.
For me, the shortcut for Goto File... is cmd+shift+O - you can check your shortcut in the menu Navigate -> File...
You can use the following format to output text in the terminal via console.log and the path will be clickable:
at ($FILE_FULL_PATH:$LINE_NUMBER:$SYMBOL_NUMBER)
Example with the full path to the file:
at (/home/ubuntu/project/index.js:12:55)
However, if you're running WebStorm with exact file path's project's folder, you can use the following format:
at (./project/index.js:12:55)
I installed Awesome Console plugin and with this plugin, all files and links in the console and terminal will be highlighted and can be clicked. Source code files will be opened in the IDE, other links with the default viewer/browser for this type.
You can jump to files from the terminal with left click
Just select file path (dblclick) & press "shift" twice (search everywhere) & press "enter"...

JSX script to Photoshop action - Is it possible?

I wonder if there exist a method to convert a simple JSX script to an action.
I have created an action and converted it to jsx in order to clean and edit it. Now, I want to convert it back to atn in order to use a keybord shorcut.
PS: I did create an action (with ctrl+F12 assigned) that calls the script, but I'd like to have a not dependant action.
Copy the JSX file into your Photoshop Script folder (PHOTOSHOP_INSTALL_FOLDER/Presets/Scripts).
For example:
C:\Program Files\Adobe\Adobe Photoshop CS6 (64 Bit)\Presets\Scripts
/Applications/Adobe Photoshop CC 2018/Presets/Scripts
Once your script is there, restart Photoshop and you see it under File > Scripts and you should be able assign keyboard shortcut to that easily using Edit -> Keyboard Shortcuts -> File (expand this) -> Scripts (expand this)
Note: If you place text like this at the top of your .jsx file, YOUR DESCRIPTION will show up on the Scripts menu:
<javascriptresource>
<name>$$$/JavaScripts/YOURNAME/Menu=YOUR DESCRIPITION</name>
<category>Scripts</category>
</javascriptresource>
#target photoshop
You can simply create an action to load the script. That's it.
You can do this by navigating Files>Scripts>Browse while recording an action, then you can assign Shortcut to it.
Hope it will help you.
record an action (with ctrl-f12 assigned) running the script.
The script needs to be in the above stated folder.

How to change indentation mode in Atom?

I haven't been able to figure this out yet. Atom seems to use spaces as the default indentation mode. I prefer to have tabs instead though. Sublime Text has built in functionality for switching and converting indentation.
Anyone found out how to change the indentation mode of Atom?
Some screenshots from Sublime Text:
See Soft Tabs and Tab Length under Settings > Editor Settings.
To toggle indentation modes quickly you can use Ctrl-Shift-P and search for Editor: Toggle Soft Tabs.
Go to File -> Settings
There are 3 different options here.
Soft Tabs
Tab Length
Tab Type
I did some testing and have come to these conclusions about what each one does.
Soft Tabs - Enabling this means it will use spaces by default (i.e. for new files).
Tab Length - How wide the tab character displays, or how many spaces are inserted for a tab if soft tabs is enabled.
Tab Type - This determines the indentation mode to use for existing files. If you set it to auto it will use the existing indentation (tabs or spaces). If you set it to soft or hard, it will force spaces or tabs regardless of the existing indentation. Best to leave this on auto.
Note: Soft = spaces, hard = tab
Add this to your ~/.atom/config.cson
editor:
tabLength: 4
OS X:
Go to Atom -> prefrences or CMD + ,
Scroll down and select "Tab Length" that you prefer.
You could try going to "Atom > Preferences > Editor" and set Tab length to 4.
This is for mac. For windows you will have to find the appropriate menu.
Adding #Manbroski answer here that worked for me:
try Ctrl-Shift-P Editor: Toggle Soft Tabs
Late to the party, but a clean way to do this on a per-project basis, is to add a .editorconfig file to the root of the project. Saves you from having to change Atom's settings when you're working on several projects simultaneously.
This is a sample of a very basic setup I'm currently using. Works for Atom, ST, etc...
http://editorconfig.org/
# Automatically add new line to end of all files on save.
[*]
insert_final_newline = true
# 2 space indentation for SASS/CSS
[*.{scss,sass,css}]
indent_style = space
indent_size = 2
# Set all JS to tab => space*2
[js/**.js]
indent_style = space
indent_size = 2
This is built into core: See Settings ⇒ Tab Type and choose auto:
When set to "auto", the editor auto-detects the tab type based on the contents of the buffer (it uses the first leading whitespace on a non-comment line), or uses the value of the Soft Tabs config setting if auto-detection fails.
You may also want to take a look at the Auto Detect Indentation package. From the docs:
Automatically detect indentation of opened files. It looks at each opened file and sets file specific tab settings (hard/soft tabs, tab length) based on the content of the file instead of always using the editor defaults.
You might have atom configured to use 4 spaces for tabs but open a rails project which defaults to 2 spaces. Without this package, you would have to change your tabstop settings globally or risk having inconsistent lead spacing in your files.
I just had the same problem, and none of the suggestions above worked. Finally I tried unchecking "Atomic soft tabs" in the Editor Settings menu, which worked.
If you are using the version 1.21.1:
Click on Packages / Settings View / Open
Select "Editor" on the left side panel
Scrool down until you see "Tab Length"
Edit the value. I like to set it to 4.
Now, just close the active tab pane and you are done.
Tab Control gives nice control in a similar manner to that described in your question.
Also nice, for JavaScript developers, is ESLint Tab Length for using ESLint config.
Or if you're using an .editorconfig for defining project-specific indentation rules, there is EditorConfig
If you're using Babel you may also want to make sure to update your "Language Babel" package. For me, even though I had the Tab Length set to 2 in my core editor settings, the Same setting in the Language Babel config was overriding it with 4.
Atom -> Preferences -> Packages -> (Search for Babel) -> Grammar -> Tab Length
Make sure the appropriate Grammar, There's "Babel ES6 Javascript Grammar", "language-babel-extension Grammar" as well as "Regular Expression". You probably want to update all of them to be consistent.
If global tab/spaces indentation settings no longer fit your needs (I.E. you find yourself working with legacy codebases with varied indentation formats, and you need to quickly switch between them, and the auto-detect isn't working) you might try the tab-control plugin, which sort of duplicates the functionality of the menu in your screenshot.
When Atom auto-indent-detection got it hopelessly wrong and refused to let me type a literal Tab character, I eventually found the 'Force-Tab' extension - which gave me back control.
I wanted to keep shift-tab for outdenting, so set ctrl-tab to insert a hard tab. In my keymap I added:
'atom-text-editor':
'ctrl-tab': 'force-tab:insert-actual-tab'
Changing language-specific configuration
I changed the default tab settings, and it still did not impact when I was editing my files, which were Python files. It also did not change when I modified the "*" setting in ~/.atom/config.cson . I don't have a good explanation for either of those.
However, when I added the following to my config.cson, I was able to change the tab in my Python files to 2 spaces:
'.source.python':
editor:
tabLength: 2
Thanks to this resource for the solution: Tab key not respecting tab length
All of the most popular answers on here are all great answers and will turn on spaces for tabs, but they are all missing one thing. How to apply the spaces instead of tabs to existing code.
To do this simply select all the code you want to format, then go to Edit->Lines->Auto Indent and it will fix everything selected.
Alternatively, you can just select all the code you want to format, then use Ctrl Shift P and search for Auto Indent. Just click it in the search results and it will fix everything selected.
Yet another answer: If you are using Atom Beautify note that it has its own settings to determine the "Indent Char".

Preserve Case Replace in Sublime Text 3

From having done a bit of googling on this it seems that it is or at least was possible to do this with Sublime Text. I have seen multiple references to a preserve case button in the find and replace pane which looks like 2 rounded squares superimposed on each other.
However, I can't find this at all in my version of Sublime Text 3 (on Mavericks)...
Also I checked preferences to see if this option was somehow turned off but the only reference I could find to it was:
{ "keys": ["super+alt+a"], "command": "toggle_preserve_case", "context":
[
{ "key": "setting.is_widget", "operator": "equal", "operand": true }
]
},
in the default key map file...
Here is a screenshot of my find and replace pane:
In the latest Sublime 3 build (3059) there is a dedicated icon in the replace dialog to preserve the case. When toggling it and using the input shown in the screenshot, the following input string will be converted to the following output:
Input: "Xhis is my xest."
Output: "This is my test."
It's not exactly an answer to your almost 1.5 years old question, but maybe you (or somebody else) find(s) the following useful:
I wrote a ST package which includes a feature to preserve the case while editing multiple selections. It even preserves cases with separators like snake_case, dash-case, dot.case etc.
It is called MultiEditUtils. Here you can see the described feature.
Looks like it might have been a glitch in ST3 that was causing confusion.
I noticed that the shortcut key combo for replace has never worked for some reason and also that selecting replace from the find menu opened the find in file pane as opposed to the regular find and replace pane (where the preserve case button is). I only realised this after installing the soda theme for ST3 which showed the preserve case button in a screenshot.
Strangely, when I reverted to the default theme, the find > replace menu now works as it should and I found that the keyboard shortcut was being causght by another program which was why it didn't work...

TextMate: Preview in Firefox without having to save document first?

Using TextMate:
Is it possible to assign a shortcut to preview/refresh the currently edited HTML document in, say, Firefox, without having to first hit Save?
I'm looking for the same functionality as TextMate's built-in Web Preview window, but I'd prefer an external browser instead of TextMate's. (Mainly in order to use a JavaScript console such as Firebug for instance).
Would it be possible to pipe the currently unsaved document through the shell and then preview in Firefox. And if so, is there anyone having a TextMate command for this, willing to share it?
Not trivially. The easiest way would be to write the current file to the temp dir, then launch that file.. but, this would break any relative links (images, scripts, CSS files)
Add a bundle:
Input: Entire Document
Output: Discard
Scope Selector: source.html
And the script:
#!/usr/bin/env python2.5
import os
import sys
import random
import tempfile
import subprocess
fname = os.environ.get("TM_FILEPATH", "Untitled %s.html" % random.randint(100, 1000))
fcontent = sys.stdin.read()
fd, name = tempfile.mkstemp()
print name
open(name, "w+").write(fcontent)
print subprocess.Popen(["open", "-a", "Firefox", name]).communicate()
As I said, that wont work with relative resource links, which is probably a big problem.. Another option is to modify the following line of code, from the exiting "Refresh Browsers" command:
osascript <<'APPLESCRIPT'
tell app "Firefox" to Get URL "JavaScript:window.location.reload();" inside window 1
APPLESCRIPT
Instead of having the javascript reload the page, it could clear it, and write the current document using a series of document.write() calls. The problem with this is you can't guarantee the current document is the one you want to replace.. Windows 1 could have changed to another site etc, especially with tabbed browsing..
Finally, an option that doesn't have a huge drawback: Use version control, particularly one of the "distributed" ones, where you don't have to send your changes to a remote server - git, mercurial, darcs, bazaar etc (all have TextMate integration also)
If your code is in version control, it doesn't matter if you save before previewing, you can also always go back to your last-commited version if you break something and lose the undo buffer.
Here's something that you can use and just replace "Safari" with "Firefox":
http://wiki.macromates.com/Main/Howtos#SafariPreview
Open the Bundle Editor (control + option + command + B)
Scroll to the HTML Bundle and expand the tree
Select "Open Document in Running Browser(s)"
Assign Activation Key Equivalent (shortcut)
Close the bundle editor
I don't think this is possible. You can however enable the 'atomic saves' option so every time you alt tab to Firefox your project is saved.
If you ever find a solution to have a proper Firefox live preview, let us know.