Thursday, March 3, 2016

Copying with tmux and vim on Fedora 23

I use tmux and vim on Fedora 23. When I have vertically split windows, selecting with my mouse cursor selects across multiple open files. Today I finally got unlazy and googled around enough to figure out how to get text into my system's clipboard (since vim uses it's own paste buffer) from vim.

I used
Conner's answer here: http://stackoverflow.com/questions/11489428/how-to-make-vim-paste-from-and-copy-to-systems-clipboard and Ignacio Vazquez-Abrams's answer here:
http://superuser.com/questions/194747/how-to-install-vim-with-clipboard-support-on-fedora
to get copy/paste working for me.
  1. install gvim
  2. create an alias in my .bashrc file so I don't have to type 'gvim -v' instead of 'vi'
  3. To select:
    1. position your cursor at the beginning of the text block you want to copy
    2. shift+v ('V')
    3. arrow down
    4. "yank" the text using "+y (keydown shift ' and +, then keyup shift, then y)
    5. Paste into a different program (like gedit, which I use as a scratch-pad) using your mouse wheel or ctrl+v
Pasting is easy.

If you're new to vim, use :paste before pasting in code-blocks to preserve formatting.