Unindent code block in IPython under cmd.exe? - ipython

I run IPython in cmd.exe as interactive shell. When typing code in this interactive shell, it does autoindent (%autoindent magic is on) or I could use Tab to indent manually, but it doesn't do unindent automatically even after line with return or raise statement, either the keyboard shortcut Shift+Tab or Ctrl+]. Is there a quick way to do undent manually instead of press Backspace for a few times?
An example is in below code with current cursor position at |, I'd like to unindent it quickly to the level of if statement.
def hello(a):
if a == 0:
return
| # | is the current cursor position.

Related

Netbeans unindent (Shift+Tab) not working when cursor is inside the line (no selection)?

In Neatbeans, unindent works as expected when multiple lines are selected. But consider the following, where the pipe character | symbolizes the cursor position in the editor:
(a) Cursor at start of line (no selection)
|hello world!
(b) Cursor inside of line (no selection)
hell|o world!
In Netbeans, when I hit Shift+Tab on version (a) then the indentation is removed. This is what I expect.
However, when I hit Shift+Tab on version (b) then nothing happens. This is different from the code editors that I am used to. I would expect the indentation to be removed, or that the cursor moves to the start of the line, such that the next Shift+Tab will remove the indentation.
Is there a config in Netbeans that makes unindent via Shift+Tab work when the cursor is inside the line?
To shift the line to the left, regardless of the cursor position you can use the "Shift line left" editor action. In the default NetBeans mapping this is assigned to Alt+Shift+KP_LEFT and Alt+Shift-LEFT
Just open the keymap options page and search for the action "shift line"
It's not exactly what you are asking, but you could try to remap that action to "Shift-Tab" and see if it works.
TLDR: There seems to be a bug in the way NetBeans handles indenting/unindenting.
I would expect the indentation to be removed
I don't see any formal documentation on how unindenting is supposed to work in NetBeans, but it appears to move the text to the right of the cursor to the left, as long as there is only whitespace to the left of the cursor. While that is different to how unindenting works in other code editors such as Intellij IDEA and Eclipse, where the entire line is shifted to the left even when the cursor is poitioned within the text, it's not necessarily incorrect.
If you want to unindent in NetBeans there are two simple alternatives: either position the cursor at the start of the line, or select some text - anything at all! - on that line before unindenting.
Some comments in the NetBeans Bug Report Bug 212353 - Shift+Tab (Delete tab) shortcut does not work in editor may be relevant:
Please note that those actions should be inverse - I mean when you
select a block and you hit <TAB> <TAB> <Shift-TAB> <Shift-TAB> you
should always end up with the same text. The same should be true if
you change the order to <Shift-TAB> <Shift-TAB> <TAB> <TAB> you
should end up with the same text.
That said, NetBeans is not adhering to that standard. Using your second example, pressing <TAB><TAB> works fine, but subsequently pressing <SHIFT><TAB> does nothing, so it is not possible to "end up with the same text". That looks like a bug (in Apache NetBeans 11.2 at least). You can raise a bug report here.
It's also worth noting that <Shift> + <Tab> is actually defined as the keymap for "Delete TAB" rather "unindenting".
Is there a config in Netbeans that makes unindent via Shift+Tab work
when the cursor is inside the line?
I don't think so. All you can do, using Tools > Options > Keymap, is to change the shortcut keys from <Shift> + <Tab> to something else, but that won't change the behavior.

Clear everything after prompt in fish shell?

I want to make keybinding that simply clears everything I entered after prompt and till the end. The same behavior as what Ctr+c does, but without appending ^C character to the end of current line and newline. Is it doable somehow?
You probably want Ctrlu and/or Ctrlk
Ctrl-u kills characters from your cursor to the start of entry (the prompt)
Ctrl-k kills characters from your cursor to the end of the line.
The deleted characters can be pasted (yanked) with Ctrly
Try this:
function clear_to_end
commandline (commandline --cut-at-cursor)
end
bind \cc clear_to_end
This sets the command line to the current command line, truncated at the cursor.

Change RET behavior in IPython shell

In IPython (5.3 in this case) pressing the RET has double meaning:
send current input to the interpreter
insert line break to the current input and let the user to modify it further
Looks like the first one is implemented only if the the cursor is in the beginning or end of the line. How can I change this behavior? For example have a separate keystroke for this purpose.
P.S. Any link to keybindings configuration in IPython would also be much appreciated.

Shortcut to get out of bracket or parenthesis in iPython

Is there a shortcut to moving the cursor from
my_variable = (entry|)
to
my_variable = (entry)
|
in iPython notebook? Where "|" is the cursor
That is, is there some shortcut you can use in place of (right arrow) followed by (return) in iPython to get out of the automatic parentheses/brackets? I feel like it would be useful to have this when coding really fast.
I found pressing 'End' & 'Enter' does the work.

set commandline shortcut in tcsh for moving cursor by word

from How to move the cursor by word in command line of tcsh I know how to move cursor by word in tcsh, but they not easy to use, so can I set a shortcut on command line for example, when I use Ctrl+leftarrow, it actually works as Esc f?
To see a list of pre-defined key-bindings, visit:
http://www.csc.fi/english/pages/data-services/linux_basics/tcsh
To see a list of all commands which can be used to configure key-bindings, visit:
http://www.rohidekar.com/sridharsarnobat/mediawiki/index.php?title=TCSH_Key_bindings
Example: (Write this in your ~/.tcshrc)
bindkey '^[^[[C' forward-word
bindkey '^[^[[D' backward-word
This will bind the alt-right with forward-word and alt-left with backword-word.
To map to a different keyset, just run cat and hit enter. Hit the key-combination (in the above example, right-arrow and left-arrow), record the strings that are echoed back, and use these as the key combinations to bind.