[Vimperator] Patch for :buffer(s) functionality

Lars Kindler lars.kindler at stud.uni-goettingen.de
Wed Apr 18 21:11:00 PDT 2007

Hi everyone,

instead of doing problem sets this afternoon, I added some functionality 
to this great
extension, namely :buffer and :buffers functionality similar to VIM's.

Insert this into your g_commands array

        ["buffer", "bu"],
        "Go to buffer number n. Full completion works.",
        function (args) {tab_go(args.split(":")[0]); 
preview_window.hidden = true},
        function (filter) {return get_buffer_completions(filter);}
        "Shows a list of all buffers.",
        function (args) {bushow("");},

Insert this into your g_mappings array

        "Shows list of buffers",
        "Typing the corresponding number opens switches to this buffer",
        function (args) { bushow(""); openVimperatorBar('buffer  '); }

and these functions wherever they fit best:

function bushow(filter) {
    items = get_buffer_completions(filter);
    preview_window.hidden = false;

function get_buffer_completions(filter) {
    var reg = new RegExp("^"+filter,"i");
    items=new Array();
    var num = getBrowser().browsers.length;
    for(var i=0; i<num;i++) {
            title = 
        } catch (e) {title = "";}
        if (title=="")
            title = "(Untitled)";
        if(title.search(reg) != -1) {
            var title;
            items.push([(i+1)+": "+title]);
    return items;

Hope this helps, I've been using it for a few hours now, and it works 
fine for me.


More information about the Vimperator mailing list