4 ms·
Vim is my primary editor but I think the only really good part of vim is the keyboard navigation. The rest could be much better. For example, to this day I hav
by VMG 16y ago
Vim is my primary editor but I think the only really good part of vim is the keyboard navigation. The rest could be much better.
For example, to this day I haven't figured out an easy, built-in way to copy from one vim window to another. I'd love to have some features of other editors have but the key bindings always hold me back.
- Sikul 16y agoHave you tried using :split and :vsplit instead of opening new windows?
- wahnfrieden 16y agoYou're not really supposed to run vim in multiple windows. Use your system pasteboard if you need to copy between them. There's probably some plugin that would make it work with yank registers though.
- njharman 16y ago> You're not really supposed to run vim in multiple windows huh? I run in 3+ windows (terminal shells) all the time and have done so for 5+ years. To cut and paste between windows I use filesystems copy and paste (select and middle click in X) Vim is flexible and you are suppose to run it however works for you.
- wahnfrieden 16y agoSure, you can -- my only point was that, as far as I know, vim doesn't really provide any help for working across multiple instances of itself.
- sophacles 16y agoSimply untrue, the number of upvotes to this saddens me. The * register exists explicitly in the default implementation for the purpose of yanking text into the system clipboard. Open your nearest vim and do :he gui-selection or :he quotestar Also, the + register has similar intended uses.
- rauljara 16y agoWith macvim I sometimes end up using cmd-c on a visually selected area, the cmd-v in the other window. It works, even if it isn't built-in. I also avoid having multiple windows open as much as possible (tabs and splits ftw) but when it does happen, I'm very grateful the standard copy/paste commands still work.
- ezy 16y agoI use a simple hack in my .vimrc com -range YY :<line1>,<line2>w! ~/tmp/cnp.txt com PP :r ~/tmp/cnp.txt Then :YY, :PP as appropriate
- ezy 16y agoOh, and this: http://vim.wikia.com/wiki/Copy_and_paste_between_Vim_instances http://vim.wikia.com/wiki/Copy_and_paste_between_Vim_instanc... has various other solutions. Including something I did not know about: You can save and load vim's state in .viminfo, so conceivably, you could yank what you want to yank, :wv in that vim, then :rv! in the other vim and paste from the exact same register or registers. Cute.. and useful for syncing up two vim windows in general.
- jng 16y agoI agree with the general point. For your example: on windows I use "yy and "p. You can set "* as default in vimrc and just use yy and p though (don't remember it off the top of my head, I can check it if you want, I use windows though)
- deleted 16y ago[deleted]
- pge 16y agoyou can copy and paste from the system clipboard as the + register - use "+y to yank to the system clipboard and "+p to paste from it (depending on OS, you may need to use * instead of +). This allows cutting and pasting between vim and other applications (including other instances of vim). For editing multiple docs with vim, I find it's easier to use multiple buffers in the same window. Use :b <start of file name> to jump back and forth.
- storborg 16y agoI never really liked using :b ... for quickly switching back and forth between files, so I bound ^hjkl to move among buffers. Perhaps the best part of my vim experience. " Use ctrl + movement keys to move around windows map <C-H> <C-W>h<C-W>_ map <C-J> <C-W>j<C-W>_ map <C-K> <C-W>k<C-W>_ map <C-L> <C-W>l<C-W>_
- Nick_C 16y ago1 ctrl-^ go to buffer 1 2 ctrl-^ go to buffer 2 3 ctrl-^ go to buffer 3 ctrl-^ toggle this buffer with the last one, quickly switching back and forth. [Of course, ctrl-^ is actually just ctrl-6, you don't need to use the shift key.] If you have used a tiling window manager before, this is very natural.
- dhimes 16y agoBut your vim has to be compiled with clipboard support. I use gvim for just this reason for all but basic editing (for which I just fire up vim).
- graywh 16y agoGenerally, gvim and vim are the same binary.
- VMG 16y agoThanks, works great. When memorize the keystrokes I hope it will be as fast as regular yanking. I actually use tabs for multiple files and these keybindings for navigation: nmap T :tabedit nmap H :tabprevious<CR> nmap L :tabnext<CR> So I can go into a project dir and do vim -p .c* which opens the file in tabs and just navigate with Shift-H and Shift-L
- kisielk 16y agoYou need to learn about registers. You can copy between windows and even use your OS's clipboard via Vim. Normally y is used to yank. However, you can prefix it with "x to yank in to register x. Then you can "xp to paste from register x. You have registers 0-9 and a-z for regular use. They work within a single window. If you use register *, the register corresponds to your OS clipboard. Read :help registers to learn more.
- hyperbovine 16y agoThere is a lot of dogma surrounding doing things the "easy way" is Vim. Cut through that and your life will be much easier. For example, I type on Dvorak and "<ESC>:w<ENTER>" is uncomfortable and arduous when all I wish to do is save a file, which I do often. Then one day I woke up and realized Apple-S works perfectly well MacVim and is many times more efficient. Getting to the point, it is easy to copy and paste between windows using the system buffer. Just map copy and paste to something easy and familiar, say Ctrl-C/V/X, and go on with your life. I'm sure there is a "correct" way to accomplish what you are asking using registers, but quite frankly I don't know it and have never felt the need to learn. (I know this assumes you are using a graphical Vim.)