Skip to content
Browse files

Initial commit.

  • Loading branch information...
0 parents commit fc194b6c6d9a68cb29eb1905d2245faa7230e9b9 @nvie committed Jul 26, 2010
Showing with 55 additions and 0 deletions.
  1. +19 −0 README.mdown
  2. +36 −0 plugin/toggle_mouse.vim
19 README.mdown
@@ -0,0 +1,19 @@
+Installation
+------------
+1. Copy the file `plugin/toggle_mouse.vim` to your `~/.vim/plugin` directory
+2. There is no step 2.
+
+
+Usage
+-----
+Press `<F12>` to toggle mouse focus between Vim and your terminal emulator,
+allowing terminal emulator mouse commands, like copy/paste.
+
+Toggling restores the Vim 'mouse' option value to its previous value.
+
+
+Customization
+-------------
+If you don't want to use the `<F12>` key for mouse toggling, simply remap it to
+another key. It autodetects whether it has been remapped and won't register
+the `<F12>` key if so.
36 plugin/toggle_mouse.vim
@@ -0,0 +1,36 @@
+"
+" Toggle mouse plugin for quickly toggling mouse between Vim and terminal
+" Maintainer: Vincent Driessen <vincent@datafox.nl>
+" Version: Vim 7 (may work with lower Vim versions, but not tested)
+" URL: http://github.com/nvie/vim-togglemouse
+"
+" Only do this when not done yet for this buffer
+if exists("b:loaded_toggle_mouse_plugin")
+ finish
+endif
+let b:loaded_toggle_mouse_plugin = 1
+
+fun! s:ToggleMouse()
+ if !exists("s:old_mouse")
+ let s:old_mouse = "a"
+ endif
+
+ if &mouse == ""
+ let &mouse = s:old_mouse
+ echo "Mouse is for Vim (" . &mouse . ")"
+ else
+ let s:old_mouse = &mouse
+ let &mouse=""
+ echo "Mouse is for terminal"
+ endif
+endfunction
+
+" Add mappings, unless the user didn't want this.
+" The default mapping is registered under to <F12> by default, unless the user
+" remapped it already (or a mapping exists already for <F12>)
+if !exists("no_plugin_maps") && !exists("no_toggle_mouse_maps")
+ if !hasmapto('<SID>ToggleMouse()')
+ noremap <F12> :call <SID>ToggleMouse()<CR>
+ inoremap <F12> <Esc>:call <SID>ToggleMouse()<CR>a
+ endif
+endif

0 comments on commit fc194b6

Please sign in to comment.
Something went wrong with that request. Please try again.