Giter Site home page Giter Site logo

ipython-vimception's Introduction

IPython Vimception

Vim-within-Vim in the IPython Notebook.

In my "Putting the V in IPython" talk at SciPy2014, I spent half of my time talking about ipython-vimception. Here are the slides for the talk.

This is a work in progress. For now, put these files into a folder called vimception (not ipython-vimception) in the extensions subdirectory of whatever ipython locate returns, usually these files go into the ~/.ipython/extensions directory.

Once you do that, in the notebook, just make an execute a cell with:

%load_ext vimception

Once you're satisfied that the above works, you can edit your profile's static/custom/custom.js to have this:

function load_vimception() {
    cell = IPython.notebook.insert_cell_at_index('code', 0);
    IPython.notebook.select(0);
    cell.set_text('%load_ext vimception\n%reload_ext vimception\n%vimception');
    if (!IPython.notebook.kernel) {
        $([IPython.events]).on('status_started.Kernel', function() {
            cell.execute();
            IPython.notebook.delete_cell();
        });
    } else { 
        cell.execute();
        IPython.notebook.delete_cell();
    }
}

$([IPython.events]).on('notebook_loaded.Notebook', function(){
    $('#help_menu').prepend([
            '<li id="vimception" title="load up vimception cell">',
            '<a href="#" title="vimception" onClick="load_vimception()">vimception</a></li>',
            ].join("\n"));

// uncomment next line to *always* start in vimception
// $('#vimception a').click();
});

This allows you to enter vimception by going clicking on Help -> vimception . To leave vimception, save and reload the notebook. If you uncomment the last line to always start vimception, there will not be a way to get out of vimception mode without editing custom.js and then reload the page.

It's all very rough right now, I'm working on it, so hang tight.

TODO

[ ] suppress switching into command mode when moving cursor past the top/bottom lines (using new methods Jonathan added)

[ ] make the multi-level escaping optional (i.e. allow only ctrl-m to take you to command mode)

[ ] look up what else I had in my todo a few weeks ago

[ ] add logic to %vimception to write vimception.json to profile_dir/static/custom - investigate json config in general (Matthias implemented this at some point)

[ ] multi-level undo

[ ] unalias v - and use nb-cccp if it's loaded

[ ] turn it into an nbextension (no python side) - implementing this should close #4 as well

[ ] Ctrl-n and Ctrl-p should work as local completion (like in vim)

[ ] on click, disable the vim fire

[ ] the cell that vimception is started from gets FUBARed :\ or actuall just entering edit mode doesn't work?

[ ] allow going between cells independent of which character you're on

[ ] shift-J on the last line should join cell below

[ ] standardize on a post-load function that vimception will call to allow for further customization.

[ ] look into the codemirror changes here

Related Projects

vim-ipython - A two-way integration between Vim and IPython by the same author.

ipython-vimception's People

Contributors

bwillers avatar davclark avatar ivanov avatar ketch avatar nbren12 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ipython-vimception's Issues

moving around cells with up/down key in "edit" mode can strand cursor

I know it's a work in progress, but just providing some feedback. Thanks a ton for working on this!

With some vigorous movement between cells using the up/down keys while in normal edit mode, I managed to "strand" an active blinking green cursor in more than one cell which was not the current active cell.

After clicking on one of these "stranded" cursors, the interface stayed in command mode, though typing would actually input text and execute commands at the same time.

yanking and pasting to and from system clipboard

Is it possible to automatically copy the content of a visual selection to the system clipboard using y? (and paste automatically using p). In other words, can I set the set clipboard=unnamedplus option somewhere in vimception? This would be very useful when copying code from online tutorials or between notebooks.

Can't get into control mode in the cell.

Hi ! It seems like with IPyton 3.0.dev it's impossible to get to command mode in a cell.
pressing esc, or control+[ , or contro+' (that's all the shortcuts I found out in the js file)
goes to the command mode of the whole notebook.
Does anyone know if it's 3.0 related ?

Everything stops working in ipython 3

I installed vimception as described in the readme. But once I start clicking into cells, the cursor just stays there and everything stops working. I can't type or anything. all I can do is leave insert mode and switch to other cells but then I can't edit those either.

edit: I can report some more details now:
Entering (ipython) insert mode i can actually type stuff, but there seems to be no way to switch between (vim) command and insert mode, only (ipython) command and insert mode.

If I execute code that results in an error message, like asdfasdfasdf, then everything stops working altogether.

once vimception, always vimception

Great stuff @ivanov ! This plugin completes the perfect working environment for me.

One thing I noticed: If I load the extension once in a notebook, vimception writes all kinds of stuff to the notebook file, which ist not reversible even if the cell loading the extension is deleted. This means once I tried out the extension in a notebook, this notebook gets always loaded with vimception enabled and syntax highlighting is always missing (issue #10).

Q: <c-h> & <esc>

(love the plugin!)

I use to backspace, as my keyboard doesn't have a backspace. Any way to do that?

Is obligatory due to how ipython notebook's modal keybindings work? Would it be possible to use as well?

I'd be happy to contribute if possible.

Cells disappear

After uncommenting the line that loads vimception by default, I've noticed that restarting the kernel and running things seems to cause cells to disappear. It's hard to reproduce, but I will see if I can figure out more. Please add a comment if you see this too.

ReferenceError: Cell is not defined

After performing
%load_ext vimception
I get the following error:

Javascript error adding output!
ReferenceError: Cell is not defined
See your browser Javascript console for more details.
Javascript error adding output!
ReferenceError: Cell is not defined
See your browser Javascript console for more details.

vimception appears to work, but I lose all syntax highlighting.

I've tested this on Ubuntu 14.04 with Chromium version 34.0.1847.116.

Cannot load vimception. Javescript errror

Hi,
I'm really excited about vimception but have trouble of loading it in ipython notebook.

when running %load_ext vimception, I got the following error message. I guess it has something to do with the vimception.js file. All the files are placed direclty under ~/.config/ipython/extensions

Javascript error adding output!
TypeError: Cannot read property 'command_shortcuts' of undefined
See your browser Javascript console for more details.
Javascript error adding output!
TypeError: Cannot read property 'command_shortcuts' of undefined
See your browser Javascript console for more details

Unfortunately, I have no experience with Java. It will be great if someone can provide some suggestions. Thanks!

Tao

Notebook shortcuts override characters for example when searching

Hi,

When going to search mode with '/' I cannot write letter s. Instead it will save the notebook. Same applies for several other characters which I assume all to be the notebook shortcuts.

I'm a novice and might be missing something fundamental in my setup. For example, I'm not able to get rid of the following error message when starting vimception
In [1]:

%load_ext vimception
Javascript error adding output!
ReferenceError: Can't find variable: Cell
See your browser Javascript console for more details.
Javascript error adding output!
ReferenceError: Can't find variable: Cell
See your browser Javascript console for more details.

css fubar

%load_ext vimception seems to fubar any css applied to the cells already present in the notebook (cells creating thereafter are fine). Screenshot:

vimception_css

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.