• Skip to primary navigation
  • Skip to main content

data Rebellion

Learning through Adventure

  • Home
  • Blog
  • Beginner Python Course
    • Preface – The Journey Ahead
    • Prologue – The Door
    • Chapter 1 – Arithmetic and Variables
    • Chapter 2 – Strings and Lists
    • Chapter 3 – Conditional Statements
    • Chapter 4 – Functions
    • Chapter 5 – Loops
    • Chapter 6 – Built-in Functions and Methods
    • Chapter 7 – Imports and Nesting
    • Chapter 8 – Opening the Door
    • Epilogue – Only the Beginning
  • About
  • Contact
You are here: Home / IDEs / Getting to Know the Spyder IDE for Python

Getting to Know the Spyder IDE for Python

Updated March 25, 2021. Published February 28, 2019. 4 Comments

Whether you’re a beginner programmer, casual coder, data analyst/scientist, or anyone else that uses Python, I’d recommend you at least check out Spyder, among other IDEs. Granted, it may not the best choice if you’re a full-time Python developer. But otherwise it has a lot to offer with its blend of intuitive, beginner-friendly design and broad, powerful set of shoulders. I mean features.

If you’re interested, see the video above for a tour of Spyder where I run you through the basics, including a set of simple keyboard shortcuts. And below you’ll find a list of said keyboard shortcuts you can follow along with.

To be clear, these aren’t the optimal shortcuts you’d get with something like Vim, and your hand will regularly have to venture over to the arrow keys and their neighbors.

XKCD Comic - Real Programmers

“Real Programmers” by xkcd, used under CC BY-NC 2.5, compressed

But you will avoid the mouse for the most part. And importantly, the learning curve is gentle so you’ll be able to focus your cognitive resources on the code. Not to mention that, if you’re a beginner, it’s going to be a while before your mind outpaces your fingers anyways.

So what I want to do here is show you the handful of shortcuts that are:

  • useful to beginners, ones that anyone could regularly use
  • reasonably intuitive, not too hard to memorize
  • Spyder’s default shortcuts, so you don’t need to make any changes
  • the same across different operating systems

Spyder Code Editor Shortcuts

First, here are the shortcuts you should know when working in the code editor.

Left/Right (Arrow Key)go back/forward a character
Up/Down (Arrow Key)go up/down a line
Shift + Left/Righthighlight previous/next character
Shift + Up/Downhighlight to cursor’s new position on next line up/down
Ctrl + Left/Rightgo to start of previous/next word
Ctrl + Shift + Left/Righthighlight to start of previous/next word
Home/Endgo to start/end of line
Shift + Home/Endhighlight to start/end of line
Ctrl + Home/Endgo to start/end of file
Ctrl + Shift + Home/Endhighlight to start/end of file
Ctrl + Lgo to Line you specify
Alt + Up/Downmove current line up/down
Highlight lines + Tabindent selected lines
Highlight lines + Shift + Tabun-indent selected lines
Ctrl + 1toggle whether a line is commented out
Ctrl + 4format line into block comment
Ctrl + 5undo block comment formatting
Backspace/Deletedelete previous/next character
Ctrl + Backspace/Deletedelete to start of previous/next word
Ctrl + DDelete line
Ctrl + Zundo
Ctrl + Shift + Zredo
Ctrl + Xcut
Ctrl + CCopy
Ctrl + Vpaste
Ctrl + Ahighlight All
Ctrl + FFind text (Enter and Shift + Enter, or F3 and Shift + F3 to cycle matches)
Ctrl + RReplace text
Ctrl + Spacecode completion
Ctrl + IInspect object (see info in help pane)
Ctrl + GGo to file and line where selected object is defined
Ctrl + Page Up/Page Downcycle to previous/next file
Ctrl + Shift + Eswitch to Editor pane
Ctrl + Shift + Iswitch to Ipython console pane
Ctrl + Shift + Vswitch to Variable explorer pane
Ctrl + Shift + Hswitch to Help pane
Ctrl + Shift + Xswitch to file eXplorer pane
Ctrl + = (or Ctrl + Mouse Wheel Forward)zoom in
Ctrl + - (or Ctrl + Mouse Wheel Back)zoom out
Ctrl + 0zoom reset
F11fullscreen mode
Ctrl + Nopen New file
Ctrl + OOpen existing file
Ctrl + SSave current file
Ctrl + Shift + SSave current file as
Ctrl + Alt + SSave all open files
F5run file
Highlight code + Ctrl + Enterrun selected code
Ctrl + Wclose file
Ctrl + Shift + Wclose all files
Ctrl + QQuit spyder

Spyder IPython Console Shortcuts

Keep in mind that many of these Code Editor shortcuts also apply to the IPython console. But there are some commands that only apply to the console, the most useful of which are the following:

Up/Downgo back/forward in command history
Ctrl + Udelete text on current line
Ctrl + L (or enter command “clear”)cLear shell
Ctrl + Topen new ipython console Tab
Ctrl + .restart kernel
Ctrl + C (or click red square in corner of pane)Cancel action, stop running script, KeyboardInterrupt

Spyder IPython Console Magic Commands

There are also special “magic” commands that you can use in the IPython console, which can take the effectiveness of Spyder to a whole new level. Try them out, and try either the %quickref or %magic commands to learn more about how to use the rest of them. If you use the %magic command though, check out the last section of this article to make sure you’re able to see all of the output.

%quickrefget list of magic commands
%magicget detailed list of magic commands
%timeget execution time of statement based on single run
%timeitget more accurate execution time of statement by averaging many runs
%histget command history of current session
%tbprint the last traceback
%resetdelete all defined variables in current namespace
%pwdget present working directory
%cdchange present working directory
%mkdirmake directory
%rmdirremove directory
%runrun file as Python program inside IPython session and make all file variables accessible
%loadimport script into code cell
%condarun conda package manager
%piprun pip package manager

Spyder IPython Console Tab Completion

When in the middle of typing something in the IPython console, such as the name of a variable, function, module, or any other object, try pressing Tab. This will do one of 3 things. 1st, if there are multiple objects whose names could match what you’ve typed so far, you will see a list options for you to choose from. You can then use the arrow keys or mouse to highlight the desired name, and press Tab to complete the name. 2nd, if there is only one possible option, the name will automatically be completed. And 3rd, if what you’ve typed so far doesn’t match anything in the namespace, then nothing will happen.

Note that, in addition to saving keystrokes on object names you’re working with, this is also helpful in exploring what methods an object contains (try hitting Tab after typing the period after the object’s name) or what objects a module contains (similar idea).

Note that normally it won’t display any names starting with underscores. To show these objects, simply include the initial underscore in what you’re typing before hitting Tab.

Tab completion also works with file paths, and function arguments too, among other things. It’s a very powerful feature. Try it out!

Spyder IPython Console Introspection (?)

Type and object’s name and then add a question mark (?) to the end of it before hitting Enter. This will return helpful information on that object. Try the same thing again, but add two question marks (??) instead. This will return the same helpful information along with the source code if it’s available.

Additionally, you can combine wildcards (*) with question marks (?) to search the IPython namespace. For example, say you’ve import pandas with import pandas as pd. And say you want to know about all the functions pandas contains related to reading files. Entering the command pd.*read*? will return every object in the top-level pandas that has contains “read” somewhere in its name. Pretty cool huh!

Increasing Spyder IPython Console Line Limit

By default, Spyder’s IPython Console will only display the last 500 lines printed to the console. When you have a lot of output, that means a lot of what you might like to see is getting cut off. Therefore, you’ll likely want to increase this line limit like so: go to Tools -> Preferences -> IPython console and on the Display tab scroll down to the Source code section where it says something like “Buffer: 500 lines” and gives you the option of changing the number. I’d recommend trying 10,000 lines and see how you like it.

So what do you think? Are you a fan of Spyder yet? Or would something like the Forbidden IDE be more your style? Let me know if you have any questions.

Python Automation Project Ideas Ebook Front Page

Free Ebook: 88 Python Project Ideas for Automating Your Life

The best way to learn programming is by working on real-world projects, so why not work on projects that also save you time and sanity? In this free, curated collection, you'll find project ideas for automating:

  • Common office tasks
  • Birthday gifts and wishes
  • Grocery and meal planning
  • Relationships (just the tedious parts!)
  • And quite a bit more

Subscribe to Data Rebellion and get this Ebook delivered straight to your inbox, as well as other exclusive content from time to time on efficiently learning to code useful things, vanquishing soul-crushing work, and having fun along the way.

Reader Interactions

Comments

  1. Anonymous says

    June 19, 2021 at 6:28 am

    it is a very interesting ide for python I am glad to say that I have never used an ide better than this!

    Reply
    • Grayson Stanton says

      June 20, 2021 at 11:41 pm

      Agreed, it’s my favorite as well. I hope they add support for Julia some day.

      Reply
  2. Anonymous says

    September 5, 2022 at 6:10 pm

    Very good information thank you

    Reply

Trackbacks

  1. Python & other tools for data analysis – solarXY says:
    April 26, 2020 at 9:45 am

    […] perfect for your data science needs. Here is a comparison of some of the most popular Python IDEs. Here you can find an introduction to working in Spyder and the editor shortcuts you will […]

    Reply

Leave a comment Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Copyright © 2023

Terms and Conditions - Privacy Policy