spyder-ide / spyder

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

Provide Vim and Emacs key bindings for the editor #669

Open spyder-bot opened 9 years ago

spyder-bot commented 9 years ago

From r.c.bruno.andre@gmail.com on 2011-05-27T12:35:31Z

Could it be possible to use vim as the text editor in Spyder?

Original issue: http://code.google.com/p/spyderlib/issues/detail?id=669

spyder-bot commented 9 years ago

From Francois...@gmail.com on 2011-05-27T12:31:48Z

I think the answer is unfortunately no ... But being myself a fan of vim modal editing and key bindings I'm with you on this point. I could be an awesome feature ... vim really rocks and spyder ide is just awesome: an happy marriage ?!

Some useful links below

Kate as an already excellent vim plugin: http://kate-editor.org/kate-vi-mode/ Emacs as also some vim-mode :) http://www.emacswiki.org/emacs/VimMode http://www.emacswiki.org/emacs/Vimpulse Netbeans as the excellent jVi plugin: http://jvi.sourceforge.net/ May I had that Pida succes in embedding vim in a really good pygtk IDE: http://pida.co.uk/ There is also vico, Kommodo edit, Gedit that have vim-mode: vicoapp.com http://www.activestate.com/komodo-edit https://launchpad.net/vigedit/

spyder-bot commented 9 years ago

From pierre.raybaut on 2011-05-28T03:33:37Z

The short answer is yes on Linux (the simplest way would be to use a QX11EmbedContainer), but no on Windows. Spyder being a cross platform IDE, we won't do things on one OS and not on the other, especially features like this one which would require a lot of work.

The examples provided by François are interesting though. But AFAIK, noone has ever successfully embedded vim in another application on Windows.

Status: WontFix
Labels: -Type-Defect Type-Enhancement

spyder-bot commented 9 years ago

From r.c.bruno.andre@gmail.com on 2011-05-28T07:37:47Z

All the other apps François mentioned look nice, but none seem to be good replacements for spyder (not scientific computation oriented).

It's too bad spyder is held back due to limitations of proprietary plateforms.

spyder-bot commented 9 years ago

From ccordoba12 on 2011-05-28T07:53:46Z

It's not only that. If we were to embed vim then soon someone else would ask to embed emacs or kate or anybody else favorite editor. That would be a real burden for the development team.

The only thing that would be possible to do is provide vim-like key bindings, as vigedit does.

Just my 2 cents, Carlos

spyder-bot commented 9 years ago

From r.c.bruno.andre@gmail.com on 2011-05-28T08:08:07Z

Vi-like key bindings would be great too.

spyder-bot commented 9 years ago

From ccordoba12 on 2011-05-28T08:43:44Z

Very well then. I'll leave this issue open as an enhancement request, in case somebody else wants to develop it.

Summary: Provide vim-like key bindings for the editor
Status: ContributorNeeded
Labels: Cat-Editor

spyder-bot commented 9 years ago

From pierre.raybaut on 2012-03-18T14:05:51Z

Labels: -Type-Enhancement Type-Enh

spyder-bot commented 9 years ago

From pierre.raybaut on 2012-03-18T14:17:01Z

Status: HelpNeeded

spyder-bot commented 9 years ago

From tbekolay on 2012-06-22T07:33:09Z

There are editors, like Sublime Text 2, that emulate Vi pretty well through a "vintage mode". I'm an emacs user, so I'm kind of itching to put emacs keybindings in Spyder, and it would make sense to have that mechanism somehow general enough to also do Vi-like key bindings.

I'm interesting in implementing such a change (though I'll likely start out with emacs keybindings), but it'll be my first code change in Spyder so it might take a while!

spyder-bot commented 9 years ago

From ccordoba12 on 2012-06-22T08:27:09Z

Don't worry about it, it could take time. Spyder has a very good shortcut support, which is also configurable. Maybe you could start taking a look at https://code.google.com/p/spyderlib/source/browse/spyderlib/plugins/shortcuts.py If you need further help please let us know

Summary: Provide Vim and Emacs key bindings for the editor

spyder-bot commented 9 years ago

From ccordoba12 on 2013-02-13T09:41:50Z

Labels: MS-v2.3

spyder-bot commented 9 years ago

From peishiy...@gmail.com on 2013-03-06T03:49:39Z

very important feature!!

spyder-bot commented 9 years ago

From ccordoba12 on 2013-03-06T08:43:13Z

Yep, totally agree. This would let people to easily move to Spyder with out leaving away their muscle memory :)

spyder-bot commented 9 years ago

From pierre.raybaut on 2013-05-11T05:32:29Z

Labels: -MS-v2.3 MS-v2.4

spyder-bot commented 9 years ago

From david.jo...@gmail.com on 2013-05-14T07:52:26Z

If someone plans to take this on, you should take a look at this vim plugin: https://github.com/ivanov/vim-ipython It allows two-way communication between vim and the ipython kernel, and works very well. It also works in gvim.

The lack of a truly powerful editor is the only thing that still keeps me from using Spyder on a regular basis.

Several of the devs I work with have expressed interest in learning python as a modeling language. To make it easier for them, I created a Python 2.7 install on an NFS mount, with a bunch of scientific tools. I even went through the trouble of figuring out how to install Spyder. It took some work, because it's not in the Centos 6 repos, and our LAN isn't connected to the internet. It required making a separate build of QT and PyQt. I figured a Matlab-like UI would lower the learning curve a bit.

The primary "IDE" where I work is vim, though I personally use Eclipse for a lot of my coding. I think it's fair to say that for most Linux devs, the editor is the most important component of the development environment. So embedding vim in Spyder would definitely increase its adoption rate.

I may take this on myself, if nobody beats me to it, as Spyder seems like a project worth investing in.

spyder-bot commented 9 years ago

From ccordoba12 on 2013-05-14T09:30:40Z

We are welcome to accept patches but we are not interested in embedding vim or emacs in Spyder at the moment.

We prefer to have a simple editor with modern features (like autocompletion, go-to-definition and error highlighting) that can be used from day one, than a powerful one but hard to configure (which has been my experience with emacs, I've not used vim).

However we are very interested in providing key-bindings to both of them so that people can easily switch to Spyder.

spyder-bot commented 9 years ago

From david.jo...@gmail.com on 2013-05-14T09:57:33Z

Emacs does require extensive effort just to create a basic dev config, IMHO, which is why I don't use it. Vim is much easier to configure and add functionality. I prefer the emacs keys, but it's not worth the time sink for me.

I've found the keyboard shortcuts in Spyder difficult to configure, and my custom shortcuts often don't work. I assume this is due to conflicts, though I couldn't find any. It would be nice if there were a warning prompt for this. It would also be much easier if you could type in the shortcuts, rather than using a dropdown.

What would be great is to be able to load bindings from a file. Is this currently possible?

I'm not a vim "shortcut ninja", but it's nice to have features like block editing.

spyder-bot commented 9 years ago

From ccordoba12 on 2013-05-14T10:58:54Z

Our shortcuts support needs a little bit of love but we plan to improve it on 2.4.

Sorry it's not possible to load bindings from a file, but it's a good idea.

By block selection you mean column selection? That would be very interesting to implement. I think there is an open issue for something like that.

spyder-bot commented 9 years ago

From david.jo...@gmail.com on 2013-05-14T14:29:01Z

Yes. Column selection. Of course, a key binding and/or button that switches the editor to column mode, like in Eclipse CDT, would be even better than the vim way.

The Spyder editor could really be much better than vim for its intended use, while allowing the user consistent muscle memory for common actions.

spyder-bot commented 9 years ago

From david.jo...@gmail.com on 2013-05-15T06:54:19Z

As far as adding vim key bindings, would it be possible to have a little command popup box for vim commands, like Vrapper in Eclipse? Or would that be too great a change to the interface?

Unfortunately, for it to really be usable, adding vim key bindings would involve more than just remapping the key combinations.

spyder-bot commented 9 years ago

From gary.pa...@gmail.com on 2015-01-09T10:26:13Z

The only thing keeping me from using Spyder is that I already have muscle memory for Emacs keybindings. It's not necessary to emulate everything, just a handful of common cases, such as next-character, kill-line, etc. I'll look into the source to see if I think I can do it.

spyder-bot commented 9 years ago

From paul.rou...@gmail.com on 2015-01-26T08:07:48Z

@-carlos #4 ccordoba12

The only thing that would be possible to do is provide vim-like key bindings, as vigedit does.

The R-Studio IDE provides vim key bindings. They are far from complete but it's a good start to navigate effectively in the page and delete, copy-paste lines.

Has someone started to implement vim key bindings?

spyder-bot commented 9 years ago

From ccordoba12 on 2015-01-30T14:23:08Z

No one is working on adding Vim key bindings for Spyder. Unfortunately that's a hard and complex project because we would have to replicate the Command/Edit mode of Vim.

However, Emacs key bindings will arrive in 2.4

fdev31 commented 9 years ago

I would really like the VIM bindings in spyder (Pycharm have it, but it's too heavy for my work's desktop). As a Python developer, how can I help ? I am NOT a Qt guy, but I tool a look into https://code.google.com/p/spyderlib/source/browse/spyderlib/plugins/shortcuts.py, I may need some doc/help around probably...

Nodd commented 9 years ago

The problem with VIM bindings is not the shortcuts themselves, it is the managment of the view and edit mode. The editor plugin itself would have to be changed (and this part of the code is already quite complicated). Unfortunately you have to know Qt to do these changes.

There may be another way to do it, but I don't know if it would work well in practice: the idea is to have a specific widget to enter the vim commands. Edit mode would be when the editor is focused, and command mode is when the widget is focused. Pressing Esc when in edit mode would give the focus to the command widget, and commands like i or a or o in the command widget would give the focus to the editor. Would it work, and would it work well ?

goanpeca commented 9 years ago

@Nodd, this is what I meant by states in some previous conversations... I think your approach would work quite nicely, and should not be that difficult to implement, but yes, @fdev31, you need quite some Qt knowledge...

Nodd commented 9 years ago

I gave it a go, it is relatively easy to do but I have one big problem: the editor doesn't have the focus anymore so the cursor is not displayed.

@fdev31 What are the most important vim commands that should be implemented ? I know just enough vim to edit config files...

goanpeca commented 9 years ago

Ok, you could "manually" draw a cursor while in the widget (Just create a new cursor QCursor()?) , based on the cursor last known position and update it behind curtains?

Nodd commented 9 years ago

Actually vim is better with a block cursor (for commands like i and a for example) so highlighting the character is maybe be the best.

Nodd commented 9 years ago

I started a plugin for vim keybinds, it's in a very early stage but it is possible to test the principle with a QLineEdit dockwidget. Only a few keys are (badly) implemented:

h
j
k
l
w
i
a
:w
:q
:wq

The plugin has the new structure to be used with #2362. To install it copy (or link) the p_vim directory to $HOME/.spyder/userplugins. Edit: and I did nothing to show the cursor.

ccordoba12 commented 9 years ago

@Nodd, that is really, really awesome!!

I'd only prefer to offer Vim support as a part of Spyder itself, given that now we are quite close to offer Emacs keybindings too ;-)

Nodd commented 9 years ago

It can be integrated in spyder along pylint and others when we want, it's just a copy-paste of a directory. I can create a PR when it's more useful/complete.

ccordoba12 commented 9 years ago

Ok, cool!

Nodd commented 9 years ago

I added a few more keys:

SPACE
ZZ
:n
:e
:e .

I'll reuse most functions added by @blink1073 for emacs keybindings once his PRs are merged.

naught101 commented 9 years ago

There is a Qt port of vim: https://bitbucket.org/equalsraf/vim-qt

It would be nice if that interface could be abstracted and used in spyder - see: https://bitbucket.org/equalsraf/vim-qt/issues/121/implement-as-a-kpart

ccordoba12 commented 9 years ago

@naught101, there's no chance we're going yo take that route. We'd provide a simple set of Vim keybindings in 3.0, and that's all :-)

h4k1m0u commented 8 years ago

Integrating the VIM key-binding to spyder would be a very interesting feature, especially for a guy like myself who migrated from Linux to Windows for Python programming (started using Anaconda recently to manage my python packages, and particularly to install numpy...). Any progress? Thanks.

Nodd commented 8 years ago

No progress on my part :disappointed: The repo with my old code is https://github.com/Nodd/spyderplugins.vim, but it uses an old plugin layout so it won't work with latest spyder. I can try to create a PR with this prototype, but I just updated Qt to 5.6 and it broke spyder. Also the plugin layout will change again soon.

fdev31 commented 8 years ago

Sorry for the very late answer, here is the list of commands I use most and I would feel frustrated if I havn't :smiley_cat:

% { } gg GG $ 0 :$ :^ :r [!] yy p m " Shift+V Ctrl+V A (CAPITAl) and I (capital) in +V modes :s & q / "macro" bindings gU gu ga [number] dd f F / :hls

Nodd commented 8 years ago

@fdev31 I can't find what some commands are supposed to do, like :$ and :^ ? The plugin should be usable now, apart from few bugs and a huge lack of implemented commands.

codestar12 commented 7 years ago

@Nodd is there anything I could do to help? I haven't contributed to Spyder before but I know python and would REALLY like to see a vim binding in Spyder.

ccordoba12 commented 7 years ago

@codestar12, please start by opening a page in the spyder-vim wiki:

https://github.com/spyder-ide/spyder-vim/wiki

with the list provided by @fdev31 above, and a short description of what all those commands do. Unfortunately none of us are Vim users, so we need your help here.

Then I'll assign some resources to keep adding functionality to that plugin on a weekly basis, until we can cover all (or at least most) of that list :-)

fdev31 commented 7 years ago

I can help more, I just missed the answers :P "$" in standard mode goes to the end of line....

Le mar. 8 nov. 2016 à 04:02, Carlos Cordoba notifications@github.com a écrit :

@codestar12 https://github.com/codestar12, please start by opening a page in the spyder-vim wiki:

https://github.com/spyder-ide/spyder-vim/wiki

with the list provided by @fdev31 https://github.com/fdev31 above, and a short description of what all those commands do. Unfortunately none of us are Vim users, so we need your help here.

Then I'll assign some resources to keep adding functionality to that plugin on a weekly basis, until we can cover all (or at least most) of that list :-)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/spyder-ide/spyder/issues/669#issuecomment-259032358, or mute the thread https://github.com/notifications/unsubscribe-auth/AAOkHmKK0FREYLRMX389AYJO9ExjxqLJks5q7-ZPgaJpZM4DhP8O .

ccordoba12 commented 7 years ago

@fdev31, please help us too! As soon as you create that wiki page, I'll ask some of our juniors to start working on improving our Vim support :-)

codestar12 commented 7 years ago

@fdev31 what does ':$', ':^', and ':r[!]' do, are those plugin specific controls? I tried them on my version of vim and they did nothing, and I couldn't find anything on them in documentation.

codestar12 commented 7 years ago

@ccordoba12 I created the wiki and have started adding the descriptions of the commands. I wasn't really sure how you wanted me to format the wiki. (I'm not sure I like how my markdown is organizing it). let me know if I should make any changes, otherwise I will finish up the last of the commands requested soon

Nodd commented 7 years ago

The wiki is not very useful to track wanted commands. It's static, you can not comment nor track evolutions or ask questions. it would be better to track implemented commands in the wiki, and wanted commands in an issue (see #1). For example I see that the wiki lists yy and p, which are both implemented. Edit: I updated the wiki page with implemented commands

sho-87 commented 7 years ago

It would be extremely useful to be able to load keybindings from an existing .vimrc file as well. Maybe even just a simple parsing of the vimrc to extract common binds (which I believe is what ideavim does for the intellij platforms: https://github.com/JetBrains/ideavim)

goanpeca commented 7 years ago

@sho-87 could you post your suggestion over https://github.com/spyder-ide/spyder-vim

CAM-Gerlach commented 6 years ago

@ccordoba12 Does this still need to be open here, or are we covered by what's on the spyder-vim repo already?