Skip to content

Instantly share code, notes, and snippets.

@igal
Created March 11, 2010 21:19
Show Gist options
  • Save igal/329662 to your computer and use it in GitHub Desktop.
Save igal/329662 to your computer and use it in GitHub Desktop.
My Vimperator configuration
"===[ Settings ]========================================================
" Autocomplete using Firefox Awesomebar subsystem
set complete=l
" Show completions as you type? '' waits for tab, 'auto' shows them immediately
set wildoptions=''
" Select the longest autocomplete match
set wildmode='list:full'
" Show a (n)umber on tabs, the (b)ottom scrollbar, and the (r)ight scrollbar
set guioptions=nbr
" Always show tab bar
set showtabline=1
" Don't beep
set noerrorbells
" Make Firefox run faster by using JIT
set! javascript.options.jit.chrome=true
"===[ Status bars ]=====================================================
" Adds RSS icon on the bottom status bar.
" From: http://blog.thetoast.net/2009/02/vimp-update.html
javascript <<EOF
(function(){
var feedPanel = document.createElement("statusbarpanel");
feedPanel.setAttribute("id", "feed-panel-clone");
feedPanel.appendChild(document.getElementById("feed-button"));
feedPanel.firstChild.setAttribute("style", "padding: 0; max-height: 16px;");
document.getElementById("status-bar").insertBefore(feedPanel, document.getElementById("security-button"));
})();
EOF
" Make bar yellow when focused.
" From: http://www.reddit.com/r/linux/comments/99d55/i_could_use_a_little_vimperator_help_also/
javascript <<EOF
(function() {
var inputElement = document.getElementById('liberator-commandline-command');
function swapBGColor(event) {
inputElement.style.backgroundColor = event.type == "focus" ? "yellow" : "";
}
inputElement.addEventListener('focus', swapBGColor, false);
inputElement.addEventListener('blur', swapBGColor, false);
})();
EOF
"===[ Auto commands ]===================================================
" Pass through all keys (like CTRL-Z) on Gmail and Google Reader:
autocmd LocationChange .* :js modes.passAllKeys = /mail\.google\.com|www\.google\.com\/reader\/view/.test(buffer.URL)
"===[ Custom commands ]=================================================
" Run :vimperatortoggle to enable or disable Vimperator as needed.
javascript function vimperatortoggle() { if (is_vimperator_active) { liberator.execute(':disable') } else { liberator.execute(':enable') }; }
command! vimperatortoggle javascript vimperatortoggle()
" Run :disable to disable Vimperator and resume normal Firefox behavior.
javascript function disable() { is_vimperator_active = false; liberator.execute(':set guioptions=TnbrmB showtabline=1'); modes.passAllKeys = true; }
command! disable javascript disable()
" Run :enable to enable Vimperator.
javascript function enable() { is_vimperator_active = true; liberator.execute('set guioptions=nbr showtabline=1') }
command! enable javascript enable()
:enable
" Load configuration file into current browser, useful for updating after editing this file.
command! sourcerc :source ~/.vimperatorrc
" Show properties of an object within JavaScript.
javascript <<EOB
function inspect(what) {
var nodes = [];
for (var node in what)
nodes.push(node);
liberator.echo(nodes.sort().join(', '));
}
EOB
"===[ Mappings ]========================================================
" Press 'F10' to toggle Vimperator
noremap <F10> :vimperatortoggle<CR>
" Press 'c' to change to a buffer, instead of 'b'
noremap c b
" Press 'b' to page up, instead of crazy CTRL-B
noremap b <PageUp>
" Press 'm' to go to previous tab
noremap m :tabprevious<CR>
" Press ',' to go to next tab
noremap , :tabnext<CR>
" Press 'q' to delete current tab
noremap q :bdelete<CR>
" Press 'C-a' to select all
noremap <C-a> <C-v><C-a>
" Press 'C-c' to copy, 'C-v' or 'S-Insert' to paste, or 'C-x' to cut
noremap <C-c> <C-v><C-c>
noremap <C-v> <C-v><C-v>
noremap <C-x> <C-v><C-x>
cnoremap <C-c> <C-v><C-c>
cnoremap <C-v> <C-v><C-v>
cnoremap <S-Insert> <C-v><C-v>
cnoremap <C-x> <C-v><C-x>
inoremap <C-c> <C-v><C-c>
inoremap <C-v> <C-v><C-v>
inoremap <S-Insert> <C-v><C-v>
inoremap <C-x> <C-v><C-x>
"===[ fin ]=============================================================
@wanyikang
Copy link

Thx, i learn from it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment