Ipython Shell Keyboard shortcuts 键盘快捷键 (Kuàijié jiàn)

In this past weekend’s coding class we practice keyboard ⌨ shortcuts in the interactive Python shell (Ipython).

Since most of the students are learning typing ⌨, practicing these keyboard shortcuts actually help them learn typing by reinforcing memory of where the keys are.

The keyboard shortcuts allows you to minimize finger movements on the keyboard, which means you don’t even have to lift your hand ✋ for the “Backspace”, ‘Home’, ‘End’ or arrow keys (most of the time).    Spend 15 minutes per day practicing these.  Pretty soon, you will be a fast coder.


keystroke Action
Ctrl-a Move cursor to the beginning of the line
Ctrl-e Move cursor to the end of the line
Ctrl-b or the left arrow key Move cursor back one character
Ctrl-f or the right arrow key Move cursor forward one character

👦Text Entry

Keystroke Action
Backspace key Delete previous character in line
Ctrl-d Delete next character in line
Ctrl-k Cut text from cursor to end of line
Ctrl-u Cut text from beginning of line to cursor
Ctrl-y Yank (i.e. paste) text that was previously cut
Ctrl-t Transpose (i.e., switch) previous two characters

🐞Command History

Keystroke Action
Ctrl-p (or the up arrow key) Access previous command in history
Ctrl-n (or the down arrow key) Access next command in history
Ctrl-r Reverse-search through command history


Keystroke Action
Ctrl-l Clear terminal screen
Ctrl-c Interrupt current Python command
Ctrl-d Exit IPython session

The shortcuts are referenced from  Python Data Science Handbook.   As its author Jake Vanderplas says, these shortcuts are not inherent in Ipython shell itself, but are based on GNU Readline library.

error: Content is protected !!