Konfigurieren Sie VIM für das Kopieren und Einfügen von Tastenkombinationen aus dem Systempuffer in Ubuntu?

20658
wonea

Wie konfiguriere ich VIM für die Verwendung von Ctrl- czum Kopieren und Ctrl- vEinfügen aus dem Systempuffer in Ubuntu?

13
http://superuser.com/questions/10588/how-to-make-cut-copy-paste-in-gvim-on-ubuntu-work-with-ctrlx-ctrlc-ctrlv/10604 innaM vor 14 Jahren 1
Darf ich empfehlen, Cream zu verwenden? http://cream.sourceforge.net/ Dies ist eine Variante von vim, die speziell für Benutzer entwickelt wurde, die sich bei der Arbeitsweise von vim nicht wohl fühlen. Rook vor 14 Jahren 0

3 Antworten auf die Frage

16

Standardverhalten in MS Windows: -

Hier ist ein Auszug aus der Datei mswin.vim: -

" CTRL-X and SHIFT-Del are Cut vnoremap <C-X> "+x vnoremap <S-Del> "+x  " CTRL-C and CTRL-Insert are Copy vnoremap <C-C> "+y vnoremap <C-Insert> "+y  " CTRL-V and SHIFT-Insert are Paste map <C-V> "+gP map <S-Insert> "+gP  cmap <C-V> <C-R>+ cmap <S-Insert> <C-R>+  " Pasting blockwise and linewise selections is not possible in Insert and " Visual mode without the +virtualedit feature. They are pasted as if they " were characterwise instead. " Uses the paste.vim autoload script.  exe 'inoremap <script> <C-V>' paste#paste_cmd['i'] exe 'vnoremap <script> <C-V>' paste#paste_cmd['v']  imap <S-Insert> <C-V> vmap <S-Insert> <C-V>  " Use CTRL-Q to do what CTRL-V used to do noremap <C-Q> <C-V> 

und das paste.vim-Skript, das für den Blockmodus Ausschneiden / Einfügen erforderlich ist: -

 " Vim support file to help with paste mappings and menus " Maintainer: Bram Moolenaar <Bram@vim.org> " Last Change: 2006 Jun 23  " Define the string to use for items that are present both in Edit, Popup and " Toolbar menu. Also used in mswin.vim and macmap.vim.  " Pasting blockwise and linewise selections is not possible in Insert and " Visual mode without the +virtualedit feature. They are pasted as if they " were characterwise instead. Add to that some tricks to leave the cursor in " the right position, also for "gi". if has("virtualedit") let paste#paste_cmd = {'n': ":call paste#Paste()<CR>"} let paste#paste_cmd['v'] = '"-c<Esc>' . paste#paste_cmd['n'] let paste#paste_cmd['i'] = 'x<BS><Esc>' . paste#paste_cmd['n'] . 'gi'  func! paste#Paste() let ove = &ve set ve=all normal! `^ if @+ != '' normal! "+gP endif let c = col(".") normal! i if col(".") < c " compensate for i<ESC> moving the cursor left normal! l endif let &ve = ove endfunc else let paste#paste_cmd = {'n': "\"=@+.'xy'<CR>gPFx\"_2x"} let paste#paste_cmd['v'] = '"-c<Esc>gix<Esc>' . paste#paste_cmd['n'] . '"_x' let paste#paste_cmd['i'] = 'x<Esc>' . paste#paste_cmd['n'] . '"_s' endi 
Fügen Sie für Windows-Benutzer, die versehentlich SEO hier (OP ist Ubuntu), "source $ VIMRUNTIME / mswin.vim" am Anfang Ihrer _vimrc-Datei hinzu. Irgendetwas, das Sie daran hindert, * die * Datei * auch unter Linux erfolgreich einzubinden? ruffin vor 10 Jahren 2
@ruffin Wenn Sie die Quelle überprüfen, werden Sie sehen, ob Anweisungen für UNIX vorliegen, sodass der Ersteller `mswin.vim` auch unter Linux verwenden konnte. RoliSoft vor 9 Jahren 1
Durch das Einfügen von "CV" zum Einfügen wird der Eingabemodus für Sonderzeichen abgebrochen: http://vim.wikia.com/wiki/Entering_special_characters#By_character_value g33kz0r vor 9 Jahren 0
0
osirisgothra

Dies ist nur minimal, vorausgesetzt, die meisten Einstellungen sind Standardeinstellungen **:

:behave mswin :set clipboard=unnamedplus :smap <Del> <C-g>"_d :smap <C-c> <C-g>y :smap <C-x> <C-g>x :imap <C-v> <Esc>pi :smap <C-v> <C-g>p :smap <Tab> <C-g>1>  :smap <S-Tab> <C-g>1< 
  • Zeile 1: bewirkt, dass die Umschalt- + Pfeile Text auswählen (und mehr *).

  • Zeile 2: macht "+ (und" *) zum Standardregister (GUI / Term-Zwischenablage)

  • Zeilen 3,4,5,6: macht Strg-x / c / v Ausschneiden / Kopieren und Einfügen

  • Zeile 7,8: Wählt TAB / SHIFT + TAB ein

Achtung: *** [: set] tings kann dieses Verhalten ändern und dass viele Anpassungen erforderlich sind, um Ihren Bedürfnissen gerecht zu werden, wie ich schon sagte, minimal. * [: verhalten] ändert viele [: set] tings die docs.

0
Eric Leschinski

Ordnen Sie Strg-V zu, um den Systembefehl auszuführen, der die Zwischenablage des Systems erfasst, in ein Register wirft und auf den Bildschirm unter dem Cursor einfügt:

vmap <C-c> y:call system("xclip -i -selection clipboard", getreg("\""))<CR>:call system("xclip -i", getreg("\""))<CR> nmap <C-v> :call setreg("\"",system("xclip -o -selection clipboard"))<CR>p 

Quelle: http://vim.wikia.com/wiki/In_line_copy_and_paste_to_system_clipboard

Das ist unnötig komplex. Sie können einfach "+ y und" + p zuordnen FliiFe vor 6 Jahren 0