spyder
spyder copied to clipboard
Add multiline editing to the Editor
From [email protected] on 2015-01-13T04:28:43Z
Is a feature of multi-editing / multi-selection planned?
Basically the idea is to be able to set multiple cursors to edit at different places of the code at the same time.
Link with the ability to select several occurrence of the same word, it can be used as a very quick "find and replace" for instance.
Here an example: http://blog.jetbrains.com/ruby/2014/03/whats-mining-multiple-cursors-and-selection/
Original issue: http://code.google.com/p/spyderlib/issues/detail?id=2112
From ccordoba12 on 2015-01-13T04:31:20Z
Nop, it hasn't been considered so far. It seems cool but I don't know how hard it will be to implement it.
Summary: Add multiline editing to the Editor (was: Feature Request)
Labels: Cat-Editor
I think with what Qt offers by default there is no (easy and clean) way to do this, so I would considered a wont fix for this one
Does QtCreator have this functionality? Because if it does, then we should be able to implement it too ;-)
I SOO want to switch to Sypder from sublime text / pycharm but multiple select/editing has become ingrained in my workflow and I find myself unable to remain for long in an editor that can't do this. PLEASE consider this.
Ok, we'll explore it for 3.1 :-)
I will look into it for 3.1
Does QtCreator have this functionality? Because if it does, then we should be able to implement it too ;-)
Alt + drag works in qtcreator 3.5.0. Now get to work !
So, here is a proof of concept :smiley:
It is doable but it is a bit hackish:
- Basically we keep track of the main and the additional cursors (here entered by
Ctrl+MouseClickfor convenience) - We make the main cursor invisible
- We set a timer and draw the main cursor (ourselves) plus any other stored additional cursor to ensure proper blinking sync
- Any keys collected in the keyPressEvent are forwarded to all cursors (if any).
Looks good!
Oh dear god thank you. SOO excited for this.
That's amazing!! I think this feature is very very very pratical!
Nice ! It looks like the cursors are a bit out of sync at the end, but I'm not 100% sure. Also a nice feature for adding a column of cursors is to use Ctrl+drag. It can be extended to a rectangular selection feature which can be very useful. It exists on geany as a plugin, I don't know if it's present in any other editor.
@Nodd, yes you are correct, the main cursor is out of sync with the rest, even though I am also manually drawing it.... but it was a 60 minute work.. so don't expect much at this point :-p
Looking forward to this! Also if ctrl-d, ctrl-u workflow could be included! :) (select next occurrence, skip select next)
@Twizzledrizzle want to give me a hand?, and also can you explain a bit more on the Ctrl+D, Ctrl+U, is that sublime-like?
Aye, sublime and atom like. I added the documenation below from sublime text. I would very much like to give you a hand, please let me know what I can do.
Multiple Selection with the Keyboard
Adding a Line
To add the line above or below to the selection, use Ctl+Alt+Up and Ctrl+Alt+down (OS X: Ctrl+Shift+Up and Ctrl+Shift+Down).
If you go too far, use Undo Selection (Ctrl+U, or Command+U on OS X) to step backwards.
Splitting the Selection into Lines
Select a block of lines, and then split it into many selections, one per line, using Ctrl+Shift+L, or Command+Shift+L on OS X.
Quick Add Next
To add the next occurrence of the current word to the selection, use Quick Add Next, which is bound to Ctrl+D on Windows and Linux, or Command+D on OS X.
Again, if you go too far, use Undo Selection (Ctrl+U, or Command+U on OS X) to step backwards.
Find All
To add all occurrences of the current word to the selection, use Find All: Alt+F3 on Windows and Linux, or Ctrl+Command+G on OS X.
Single Selection
To go from multiple selections to a single selection, press Escape.
This is also one of the primary things keeping me from using spyder as my main IDE. I love spyder for the variable explorer, but without multi cursor support the editing experience is not as fluent as something like sublime. For example, Using Ctrl-D to highlight next occurrence of the highlighted word and editing all selections in one go is a massive time saver
Just a remark, but is Ctrl+D really better than Replace All ? It looks cooler but the functionality looks the same. (Also Ctrl+D is currently set as delete current line).
Having used both Replace All and multiple cursors, for me multiple cursors is much faster in most cases. And it also opens up possibilities that are not as easy with regex & replace all.
There is a good discussion in a NeoVim issue that I took this screenshot from

https://github.com/neovim/neovim/issues/211
Hi, I was just wondering if the multiple cursor functionality is available in Spyder currently. I really like Spyder and it would be super nice to have this functionality. Thanks!
No, it's not available currently. You can see it as an opportunity to become a spyder contributor !
+1 for multiple cursors!
Hello,
I was wondering, what part of the code would need to be modified?
Because, I wanted to have a look whether I could try to do it (although I am quite a newbie in software programming), but I did not find explanations on the code structure :/ and I found myself a bit lost. Maybe that could help potential coders to explain where and maybe roughly how it could be done.
Thank you!
@Nodragem thanks for the help. I will ping you back with some details later today or tomorrow.
Cheers :-)
Bumping this. Would be such a great feature.
I think it would be nice to have this implemented in the same way Kate does it. Just press ctrl+shift+b and you are on column editing mode, press it again and you are back to line editing.
This is really a must have feature for Spyder. I'm actually impressed that Spyder lacks this feature.
We are working on major improvements to the code editor and this would be one of such improvements
Is anyone developing this? I checked up the QtCreator source. In the file "texteditor.cpp", there is a "BlockSelection Mode" implemented for "TextEditorWidgetPrivate". I think it might take some time to find out which parts are relevant to take over and which not, but I think it is doable in principle from Qt based TextEdit widgets. At least we have the basic logic implemented there. However, this is different from the Sublime text version described by @Twizzledrizzle .
@rlaverde would you like me to work on this one? I think it is something I could do and that I would like to have in Spyder as well.
@jnsebgosselin yes, go ahead, I'm not currently working on this