Bram Moolenaar | 0fd9289 | 2006-03-09 22:27:48 +0000 | [diff] [blame] | 1 | " Vim support file to help with paste mappings and menus |
| 2 | " Maintainer: Bram Moolenaar <Bram@vim.org> |
Bram Moolenaar | 8aba950 | 2006-06-23 15:25:34 +0000 | [diff] [blame] | 3 | " Last Change: 2006 Jun 23 |
Bram Moolenaar | 0fd9289 | 2006-03-09 22:27:48 +0000 | [diff] [blame] | 4 | |
| 5 | " Define the string to use for items that are present both in Edit, Popup and |
| 6 | " Toolbar menu. Also used in mswin.vim and macmap.vim. |
| 7 | |
| 8 | " Pasting blockwise and linewise selections is not possible in Insert and |
| 9 | " Visual mode without the +virtualedit feature. They are pasted as if they |
| 10 | " were characterwise instead. Add to that some tricks to leave the cursor in |
| 11 | " the right position, also for "gi". |
| 12 | if has("virtualedit") |
| 13 | let paste#paste_cmd = {'n': ":call paste#Paste()<CR>"} |
| 14 | let paste#paste_cmd['v'] = '"-c<Esc>' . paste#paste_cmd['n'] |
Bram Moolenaar | 8aba950 | 2006-06-23 15:25:34 +0000 | [diff] [blame] | 15 | let paste#paste_cmd['i'] = 'x<BS><Esc>' . paste#paste_cmd['n'] . 'gi' |
Bram Moolenaar | 0fd9289 | 2006-03-09 22:27:48 +0000 | [diff] [blame] | 16 | |
| 17 | func! paste#Paste() |
| 18 | let ove = &ve |
| 19 | set ve=all |
| 20 | normal! `^ |
| 21 | if @+ != '' |
| 22 | normal! "+gP |
| 23 | endif |
| 24 | let c = col(".") |
| 25 | normal! i |
| 26 | if col(".") < c " compensate for i<ESC> moving the cursor left |
| 27 | normal! l |
| 28 | endif |
| 29 | let &ve = ove |
| 30 | endfunc |
| 31 | else |
| 32 | let paste#paste_cmd = {'n': "\"=@+.'xy'<CR>gPFx\"_2x"} |
| 33 | let paste#paste_cmd['v'] = '"-c<Esc>gix<Esc>' . paste#paste_cmd['n'] . '"_x' |
| 34 | let paste#paste_cmd['i'] = 'x<Esc>' . paste#paste_cmd['n'] . '"_s' |
| 35 | endif |