spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.25k stars 1.6k forks source link

Add multiline editing to the Editor #2112

Open spyder-bot opened 9 years ago

spyder-bot commented 9 years ago

From geoffrey...@gmail.com 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

spyder-bot commented 9 years ago

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

goanpeca commented 9 years ago

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

ccordoba12 commented 9 years ago

Does QtCreator have this functionality? Because if it does, then we should be able to implement it too ;-)

xguse commented 9 years ago

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.

ccordoba12 commented 9 years ago

Ok, we'll explore it for 3.1 :-)

goanpeca commented 9 years ago

I will look into it for 3.1

Nodd commented 9 years ago

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 !

goanpeca commented 9 years ago

So, here is a proof of concept :smiley:

It is doable but it is a bit hackish:

blink1073 commented 9 years ago

Looks good!

xguse commented 9 years ago

Oh dear god thank you. SOO excited for this.

Nodragem commented 9 years ago

That's amazing!! I think this feature is very very very pratical!

Nodd commented 9 years ago

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.

goanpeca commented 9 years ago

@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

Twizzledrizzle commented 8 years ago

Looking forward to this! Also if ctrl-d, ctrl-u workflow could be included! :) (select next occurrence, skip select next)

goanpeca commented 8 years ago

@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?

Twizzledrizzle commented 8 years ago

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.

sho-87 commented 8 years ago

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

Nodd commented 8 years ago

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).

Twizzledrizzle commented 8 years ago

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 multicursor

https://github.com/neovim/neovim/issues/211

cocoaaa commented 8 years ago

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!

Nodd commented 8 years ago

No, it's not available currently. You can see it as an opportunity to become a spyder contributor !

brooksandrew commented 8 years ago

+1 for multiple cursors!

Nodragem commented 8 years ago

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!

goanpeca commented 8 years ago

@Nodragem thanks for the help. I will ping you back with some details later today or tomorrow.

Cheers :-)

akapocsi commented 8 years ago

Bumping this. Would be such a great feature.

arielwrl commented 8 years ago

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.

goanpeca commented 8 years ago

We are working on major improvements to the code editor and this would be one of such improvements

vkmaheshbhat commented 7 years ago

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 .

jnsebgosselin commented 7 years ago

@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.

rlaverde commented 7 years ago

@jnsebgosselin yes, go ahead, I'm not currently working on this

RomeshA commented 7 years ago

Actually a related question is whether it is possible to set an external editor? In Matlab's preferences you can set an external editor command so that double clicking files in the File Explorer (or via 'edit') opens them externally (e.g. in Sublime Text or Atom etc.) rather than in Matlab's own editor. I imagine there are plenty of users who already have familiar text workflows and could be easier for users to use them where they are rather than re-implementing within Spyder?

arielwrl commented 7 years ago

I don't think this is a good idea. Multiline editing is a basic feature for any modern editor.

Ariel WerleGrupo de Astrofísica - UFSC

On Thu, Aug 10, 2017 at 7:37 AM, Romesh Abeysuriya <notifications@github.com

wrote:

Actually a related question is whether it is possible to set an external editor? In Matlab's preferences you can set an external editor command so that double clicking files in the File Explorer (or via 'edit') opens them externally (e.g. in Sublime Text or Atom etc.) rather than in Matlab's own editor. I imagine there are plenty of users who already have familiar text workflows and could be easier for users to use them where they are rather than re-implementing within Spyder?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/spyder-ide/spyder/issues/2112#issuecomment-321515573, or mute the thread https://github.com/notifications/unsubscribe-auth/ASbKRd1j4XhjHLFPm5zH8A9c43QhKtu2ks5sWt1NgaJpZM4DhxiD .

ccordoba12 commented 7 years ago

@RomeshA, that's not related to this issue.

jnsebgosselin commented 7 years ago

test4

Of course, this is a work in progress. @ccordoba12 and @rlaverde Could you take a look at it and tell me what you think and how and if this could be incorporated to the Spyder framework? Thank you. (https://github.com/jnsebgosselin/PySide-Custom-Widgets/blob/master/multicursor_editor.py).

ccordoba12 commented 7 years ago

@jnsebgosselin, really cool! @rlaverde, please point him to the right place to integrate this in Spyder.

ccordoba12 commented 7 years ago

This is not ready @andfoy :-)

andfoy commented 7 years ago

Sorry, I pushed that button from my phone! :-)

rlaverde commented 7 years ago

you should modify CodeEditor https://github.com/spyder-ide/spyder/blob/master/spyder/widgets/sourcecode/codeeditor.py#L206

I think will be enough to add that code to the corresponding methods, although I'm not sure if that will be easy in some complex complex methods like the keyPressEvent()

@ccordoba12 Or should we try to modularize the already complex CodeEditor? I'm not sure how, maybe mixings.

jitseniesen commented 7 years ago

@jnsebgosselin Looks really good! Promising to see that it's possible with Qt.

a1ultima commented 6 years ago

+1 for multi-line editing

adareau commented 6 years ago

:+1: This will be indeed a killer feature

phildias commented 6 years ago

Any updates on this? Pretty please? With a cherry on top? =)

jnsebgosselin commented 6 years ago

What should the shortcuts be for this feature? @ccordoba12 ?

ccordoba12 commented 6 years ago

I really don't know. Please check what the default shortcut is in Sublime, Atom and VSCode and use the most common one. Thanks!

jnsebgosselin commented 6 years ago

I really don't know. Please check what the default shortcut is in Sublime, Atom and VSCode and use the most common one. Thanks!

The problem is that we do not have a lot of options that are not already taken in Spyder... I think I will go with :

Ctrl + Shift + Up /Down /Click

to add cursors one by one, and with :

Ctrl + Shift + L

to add one cursor per line of a selected text block.

ccordoba12 commented 6 years ago

Ok, thanks!

rBatt commented 6 years ago

Holding down Alt to engage multi-line selection is common; if you start typing, after a multiline selection, it becomes editing. Textmate2 does it like this, I think SublimeText3 does too (both hotkey and sequence).

MohamedKiouaz commented 5 years ago

I think this is an important feature. It's really annoying to have to copy paste to NotePad++ every time I need multi-line editing. Would be really nice if this gets to stable. Thanks for the hard work.

jnsebgosselin commented 5 years ago

Sorry this has not received as much attention as it should. I cannot resume working on this before some issues I am working on with keyboard shortcuts are resolved first. I am confident though that we will be able to make this feature part of Spyder4.

a1ultima commented 5 years ago

Brilliant news! Looking forward to it

On Thu, 18 Oct 2018, 20:42 Jean-Sébastien Gosselin, < notifications@github.com> wrote:

Sorry this has not received as much attention as it should. I cannot resume working on this before some issues I am working on with keyboard shortcuts are resolved first. I am confident though that we will be able to make this feature part of Spyder4.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/spyder-ide/spyder/issues/2112#issuecomment-431135284, or mute the thread https://github.com/notifications/unsubscribe-auth/AGKa_jdEwlQ3eAyQhlBs91dcMct5FPhaks5umNmIgaJpZM4DhxiD .