LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 12-12-2021, 03:19 AM   #1
arfon
Member
 
Registered: Apr 2004
Distribution: Slackware & RHEL
Posts: 376

Rep: Reputation: Disabled
VIM won't let me copy text in X


VIM won't let me copy a portion of text (in XFCE Term). COPY is grey'd out. You can only select ALL text and copy. It wasn't like this before.

What setting needs to be changed to allow the WM to manage copies?
 
Old 12-12-2021, 03:47 AM   #2
slac
Member
 
Registered: May 2019
Posts: 265

Rep: Reputation: Disabled
You will need to change the vim's clipboard setting by:

Code:
set clipboard=unnamedplus
Either enter that in a vim session (command) or put it in your .vimrc.

However be aware that Slackware's default VIM package does not have such functionality. You will need to recompile VIM with the --with-x switch at the configure command before building.

You can check if your VIM has X11 clipboard functionality by checking:

Code:
vim --version | grep X11
If the command shows "+X11" then you have it (the x11 clipboard), if it appears -X11 then you will need to recompile as I said earlier.

Last edited by slac; 12-12-2021 at 07:49 AM. Reason: spell-checking
 
2 members found this post helpful.
Old 12-12-2021, 03:48 AM   #3
pghvlaans
Member
 
Registered: Jan 2021
Distribution: Slackware64 {15.0,-current}, FreeBSD, stuff on QEMU
Posts: 452

Rep: Reputation: 364Reputation: 364Reputation: 364Reputation: 364
I'm not what options would be needed for the context menu, but adding ":set clipboard=unnamedplus" to ~/.vimrc and calling vim with "gvim -v" (setting an alias is handy) has always worked for me. Copy in VISUAL mode with yy, and paste in INSERT mode with Ctrl+Shift+V.
 
1 members found this post helpful.
Old 12-12-2021, 12:51 PM   #4
enorbet
Senior Member
 
Registered: Jun 2003
Location: Virginia
Distribution: Slackware = Main OpSys
Posts: 4,784

Rep: Reputation: 4435Reputation: 4435Reputation: 4435Reputation: 4435Reputation: 4435Reputation: 4435Reputation: 4435Reputation: 4435Reputation: 4435Reputation: 4435Reputation: 4435
Oh yeah! VIM... it's crunchy!
 
Old 12-12-2021, 03:33 PM   #5
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019Reputation: 5019
If you want to paste from the X11 "PRIMARY selection" using the middle mouse button in the usual manner you will need to add set mouse="" into your vimrc.
 
1 members found this post helpful.
Old 12-13-2021, 06:53 PM   #6
ethelack
Member
 
Registered: Mar 2021
Location: New Zealand
Distribution: Slackware
Posts: 81

Rep: Reputation: Disabled
Heres a description how to recompile vim --with-x using the slackbuild script.

mkdir -p ~/tmp/vimbuild
cd ~/tmp/vimbuild

# list the version of the dependency file ctags at slackware.com
Code:
lftp -e "cls -1 > /tmp/list; exit" "https://mirrors.slackware.com/slackware/slackware64-current/source/ap/vim/" && grep -m 1 -e "ctags" /tmp/list && rm /tmp/list
# current output is: ctags-5.8.tar.xz

# download the ctags file
Code:
wget https://mirrors.slackware.com/slackware/slackware64-current/source/ap/vim/ctags-5.8.tar.xz
# download vim.SlackBuild
Code:
wget https://mirrors.slackware.com/slackware/slackware64-current/source/ap/vim/vim.SlackBuild
# modify vim.SlackBuild for x functionality
Code:
sed -i -e '/--with-compiledby/i \  --with-x \\' -e 's/config_vim --without-x --disable-gui/config_vim --with-x --enable-gui/' vim.SlackBuild

chmod 755 vim.SlackBuild

su root

# build the vim package
./vim.SlackBuild

# remove vim if it is already installed
removepkg vim

#install the modified vim
installpkg /tmp/vim-*.txz

As user you can put these options in your .vimrc file

" turn on Ctrl+c,v keys to copy,paste
vnoremap <C-c> "+y
map <C-v> "+P

" copy to both the clipboard and primary
vnoremap <C-c> y :let @+=@"<CR>

Last edited by ethelack; 12-14-2021 at 05:44 PM.
 
Old 12-14-2021, 06:38 AM   #7
slacktroll
Member
 
Registered: May 2011
Distribution: Slackware64/current
Posts: 175

Rep: Reputation: 45
Hmm, i usually mark the text in a window with the mouse pointer.
to copy the text to vim i press I as insert and then press shift + insert and it paste from the X11 buffer.

Copying from the actual terminal (urxvt/rxvt-unicode where vim is running) i press shift+mouse1 to mark the text with the mouse pointer
and it's copy able to other terminals

Hmm, hope this helps..
 
1 members found this post helpful.
Old 12-14-2021, 07:00 PM   #8
caffe
LQ Newbie
 
Registered: Feb 2015
Posts: 17

Rep: Reputation: Disabled
Quote:
Originally Posted by pghvlaans View Post
I'm not what options would be needed for the context menu, but adding ":set clipboard=unnamedplus" to ~/.vimrc and calling vim with "gvim -v" (setting an alias is handy) has always worked for me. Copy in VISUAL mode with yy, and paste in INSERT mode with Ctrl+Shift+V.
This is the correct answer. There is no need to recompile vim. Simply use the one Pat ships with X11 support already built in.

See also this previous thread:
https://www.linuxquestions.org/quest...7/#post5765865
 
Old 12-15-2021, 01:34 AM   #9
fourtysixandtwo
Member
 
Registered: Jun 2021
Location: Alberta
Distribution: Slackware...mostly
Posts: 317

Rep: Reputation: 209Reputation: 209Reputation: 209
Another option is to make nvi the default symlink to vi instead of vim. It's great that Patrick made that an installation choice for the upcoming 15 release.

Vim has a lot of great features, but needs to have sane defaults that don't break the basic expected UI functionality.
 
Old 12-15-2021, 03:31 AM   #10
_peter
Member
 
Registered: Sep 2014
Location: paris
Distribution: slackware
Posts: 314

Rep: Reputation: Disabled
here native vim w/ -X11 shipped in Slackware 15 RC2 has no issue copying and pasting when started from an xfce4-terminal.
deliberately choosing to reset the mouse macro to remove the all mode in the .vimrc : the center mouse button is used for the copy paste.
Code:
set mouse=v
you may be talking of gvim instead ?
Attached Thumbnails
Click image for larger version

Name:	Screenshot_2021-12-15_10-22-33.png
Views:	30
Size:	94.4 KB
ID:	37862  
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: How To Copy A Block Of Text In Vim LXer Syndicated Linux News 0 10-13-2020 04:12 AM
[SOLVED] Fedora shows 'man vim' but when execute 'vim' got "bash: vim: command not found..." ? flash_os Linux - Newbie 19 01-03-2015 11:56 PM
Switching from vim to vim -g from inside vim iDragoon Linux - Software 4 05-15-2009 11:46 AM
Editor comparison: vim VS vim-lite, Cleaning vim Ruler2112 *BSD 4 04-13-2009 04:26 PM
Why won't it let me copy or move a file from one directory to another? dewjunkie Linux - Newbie 4 01-23-2008 12:31 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 11:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration