├── .gitignore ├── README.md ├── autoload └── omnipresence.vim ├── os ├── linux │ └── vim_omni.sh └── windows │ ├── AutoHotkey.exe │ ├── compile.ahk │ ├── vim.ico │ └── vim_omni.ahk └── plugin └── omnipresence.vim /.gitignore: -------------------------------------------------------------------------------- 1 | /Config.ini 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # vim-omnipresence 2 | 3 | **NOTE**: Work in progress! 4 | 5 | This vim plugin creates hotkey to launch vim for any common operating system editable area. You can then change the text, save the document and exit. The text in the editable area should be replaced with your changes done in vim editor. 6 | 7 | ### Installation 8 | 9 | NeoBundle 'majkinetor/vim-omnipresence' "{{{ 10 | let g:omnipresence_hotkey = 'F11' 11 | "}}} 12 | 13 | ### Status 14 | 15 | * Windows support: Full 16 | * This will launch AutoHotkey script which will be visible in the system tray (using vim icon). Script will automatically install itself in the Startup folder of the current user. Hotkey can be configured via `vimrc`. To uninstall it, execute `:call omnipresence#uninstall()`. To toggle it use `:call omnipresence#toggle()` 17 | * Set mapping: `let g:omnipresence_hotkey = 'F11'` (note: key mapping is currently [AHK style](http://www.autohotkey.com/docs/misc/Remap.htm)) 18 | * Linux support: Partial 19 | * No automatic hotkey creation 20 | * No automatic dependency installation 21 | * Mac support: ? 22 | 23 | ### Related work 24 | 25 | * [cknadler / vim-anywhere](https://github.com/cknadler/vim-anywhere) 26 | * Windows 27 | * [Bring vim's key bindings to the desktop](https://github.com/mihaifm/vim.ahk) 28 | * [Edit everywhere with vim](http://www.autohotkey.com/board/topic/78526-edit-everywhere-with-vim/) 29 | -------------------------------------------------------------------------------- /autoload/omnipresence.vim: -------------------------------------------------------------------------------- 1 | let s:save_cpo = &cpo | set cpo&vim 2 | if exists('g:loaded_omnipresence') | finish | en 3 | 4 | let s:RootDir = expand(':p:h:h') 5 | let s:Ahk = shellescape(s:RootDir . '/os/windows/AutoHotKey.exe') 6 | let s:AhkScript = shellescape(s:RootDir . '/os/windows/vim_omni.ahk') 7 | 8 | let s:config = s:RootDir . '/Config.ini' 9 | let s:cfg_lines = filereadable(s:config) ? readfile(s:config) : [] 10 | let s:disabled = index(s:cfg_lines, 'disabled=1') != -1 11 | let s:uninstall = index(s:cfg_lines, 'uninstall=1') != -1 12 | 13 | 14 | fu! s:run_ahk() 15 | sil exe '!start ' . s:Ahk . ' ' . s:AhkScript 16 | endf 17 | 18 | fu! s:config_update() 19 | let cfg = s:config_createlist() 20 | if !s:config_shouldUpdate(cfg) | retu | en 21 | call writefile(cfg, s:config) 22 | endfu 23 | 24 | fu! s:config_createlist() 25 | let lines = ['[Config]'] 26 | let lines += [ 'path=' . $VIMRUNTIME . '/gvim.exe'] 27 | 28 | let vars = [ 'hotkey', 'vimoptions', 'uninstall', 'disabled' ] 29 | for var in vars 30 | let g_var = 'g:omnipresence_' . var 31 | let s_var = 's:' . var 32 | if exists(g_var) | let lines += [ printf('%s=%s', var, eval(g_var)) ] | en 33 | if exists(s_var) | let lines += [ printf('%s=%s', var, eval(s_var)) ] | en 34 | endfor 35 | retu lines 36 | endfu 37 | 38 | fu! s:config_shouldUpdate(cfg) 39 | if !filereadable(s:config) | retu 1| en 40 | let lines = readfile(s:config) 41 | 42 | let a = join(lines, '\n') 43 | let b = join(a:cfg, '\n') 44 | 45 | retu a!=b 46 | endfu 47 | 48 | 49 | fu! omnipresence#ensure_running() 50 | if s:uninstall | retu | en 51 | 52 | call s:config_update() 53 | if has('win32') 54 | call s:run_ahk() 55 | en 56 | endfu 57 | 58 | fu! omnipresence#toggle() 59 | let s:disabled = !s:disabled 60 | call s:config_update() 61 | endfu 62 | 63 | fu! omnipresence#uninstall() 64 | let s:uninstall=1 65 | call s:config_update() 66 | endfu 67 | 68 | let &cpo = s:save_cpo | unlet s:save_cpo 69 | let g:loaded_omnipresence = 1 70 | -------------------------------------------------------------------------------- /os/linux/vim_omni.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Deps: 4 | # Ubuntu/Debian : sudo apt-get install xdotool xsel 5 | # RH : yum install xdotool xsel 6 | # OpenSuse : zypper install xdotool xsel 7 | # Mac : sudo port install xdotool 8 | # For hotkey : xkeybind 9 | # "vim_omni" 10 | # Mod2 + F12 11 | 12 | xdotool -< /tmp/vimy 18 | gvim --nofork '+$|set ff=unix|startinsert!' /tmp/vimy 19 | cat /tmp/vimy | xsel -bi 20 | xdotool - <