Select mulitple lines without mouse in Spyder - python

I use MacOS. With other editors I've used, I can hold down Control+Shift followed by a combination of p or n to select multiple lines above or below the current point. I've read through the keybindings under Preferences -> Keyboard shortcuts but I can't figure it out.

(Spyder maintainer here) Sorry but it's not possible to do what you want in Spyder.

Related

How to wrap lines automatically in Python Spyder?

I'm new to Python.
I'm using Spyder 4.0.1, Python 3.7.
The Spyder built-in PEP-8 convention code style check returns error E501 (line too long). Although I set the vertical line and wrap lines, it still shows error for the long characters line. Pycharm would wrap lines automatically, but I cannot find any effective solution in Spyder.
What should I do? Do I have to press Enter manually for the long line? Thanks.
In Windows Go To
Tools->Preferences->Editor and select Wrap lines.
If you use mac, you need to go to Python on the left right corner then click on Preferences.
Then go to Editor, and check Wrap lines.
To turn on the Word Wrap feature, go to View > Toggle Word Wrap or click the Edit Display icon in the Code Editor toolbar (it's the second-to-last one on the right) and select Toggle Word Wrap. You can also set the program preferences to keep this feature on by default.

What is the shortcut key to comment multiple lines using PyCharm IDE?

In Corey Schafer's Programming Terms: Mutable vs Immutable, at 3:06, he selected multiple lines and commented them out in PyCharm all in one action.
What is this action? Is it a built-in shortcut in PyCharm that I can use or configure myself?
This is a setting you can change and define in "Settings".
The default is with Ctrl+/ for Windows, or Cmd+/ for Mac.
Years later: on AZERTY keyboard, '/' from syntax area (;.:/!ยง,?), AKA "slash" does not work!
You have to use the '/' symbol from numbers area (division symbol).
Is depends on you're text editor , but probably all text editor use (ctrl + /) just highlight all the code you need to comments and use the shortcut , to know what shortcut using in you're favorite text editor search in google : YourTextEditor shortcuts
If you use macbook build-in keyboard, this shortcut does not work. So you can assign new shortcut for this purpose by following steps;
1.Go keymap menu
PyCharm -> Preferences -> Keymap
2.Find "comment with line comment" then click pencil sign "add keyboard shortcut" then assign your custom shortcut (press your favorite keyboard combination)
This heavily depends on where you're writing your python code. If you're writing it in Notepad, there won't be a shortcut for commenting a line.
However, if you use an IDE, you will probably have such capability alongside the ability to change the shortcut.
Just search Google for keyboard shortcuts for your preferred IDE.

Spyder Python Shortcut to Select All Text Above Current Line

Let's say I'm on line 500 in spyder, and I want to run everything from that line and above (lines 1-500), is there a shortcut to select the lines quickly. Right not I'm highlighting the lines and scrolling up and using shift and up arrow but both of them take some time to scroll. Is there a faster way to select, similar to select all but only for the specific lines 1-500?
(Spyder maintainer here) The easiest way to do what you want is by creating code cells. These are sections in your file separated by comments of the form # %%, which can be run independently by placing the cursor inside them and pressing the shortcuts Ctrl+Enter (run cell) and Shift+Enter (run cell and and advance to the next one).
Please refer to our documentation for more details.
This post is old I know, but I found out that CTRL-Shift-Home doesn't work for me.
I have to use CTRL-Alt-Shift-Home to select everything above the line or -End for everything below.
This is for Windows 7 and Spider 3.3.6
Just in case someone is interested in deleting all the lines, and only find this question after searching, the easy way would be using
'''
for all the codes between the two lines, and then use the triangle on the left to suppress, so you could delete in one go.

Python: Entire Script 1 Tab backwards?

I want to shift back the entire code 1 tab backwards. Is that possible? What is the key commbination? I am using Idle 3.6.3 on an Mac OSX System.
Thanks for the help!
Whilst it's absolutely a question about your editor rather than Python, many editors actually use the same key combo for this. On my Mac, it's the same in VS-Code, Sublime3 and TextMate:
cmd-a to select all text (or select a smaller region if you prefer)
cmd-[ to un-indent the selected block one stop (and cmd-] to indent)
Here's a video I made demonstrating the process in TextMate on a MacBook Pro:
https://www.youtube.com/watch?v=vyHRi2xXAnA

Python IDLE equivalent of CTRL-R in R

If you have a script open in the Windows version of R, you can run a line (or section of highlighted code) in the shell by hitting CTRL-R (believe it's command-enter in apple version). Is there similar functionality for IDLE? Many thanks
No
In the shortcut key list in IDLE, in Options > Configure IDLE > Keys, in the Action - Key(s) list, one does not find any shortcut key for executing selected code.
IDLE with IdleX supports the ability to run a single line of code or a selection by pressing F9. It also has subCodes which allows you to run code in between '##' comments. It has the same effect as highlighting a lot of code for execution, but you don't need to keep highlighting each time.
If you type part of your search string before hitting Alt+P, then Alt+P will find only items starting with what you typed.
Pasting here from my own answer at https://stackoverflow.com/a/27702886/492336

Categories

Resources