I was trying to map ctrl+c to copy, ctrl+v to paste in vim, but it's not working properly.I've tried https://stackoverflow.com/questions/61177658/mapping-select-all-copy-paste-in-vim and https://superuser.com/questions/61226/configure-vim-for-copy-and-paste-keyboard-shortcuts-from-system-buffer-in-ubuntu. I've mapped Ctrl+c to vnoremap "+y and Ctrl+v to vnoremap "+p. What am I doing wrong? my .vimrc

set nocompatible
filetype off
filetype off
set rtp+=~/.vim/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
Plugin 'preservim/nerdtree'
Plugin 'ackyshake/VimCompletesMe' 
Plugin 'vim-airline/vim-airline' 
Plugin 'jiangmiao/auto-pairs'
call vundle#end()
filetype plugin indent on
"set line number
set number
"set syntax highlight
syntax on
"set highlight search
set hlsearch
"turns on detection,plugin and indent at once of a given file
filetype plugin indent on
" 80 characters line
"set colorcolumn=81
"set terminal color to 256 colors
set t_Co=256
"set tabulations of 8 white spaces
set shiftwidth=8
"set visual bell
set visualbell
"background color: dark
set background=dark
"set indentation reacts to the syntax of the code
set smartindent
"automatically indent new lines
set autoindent
"autoindent lines
nmap <C-s> :w<CR>
"map Ctrl+s to save in normal mode
imap <C-s> <Esc>:w<CR>l
"map Ctrl+s to save in insert mode
nmap <C-d> :ClangFormat<CR>
"map Ctrl+d to format code
imap <C-d> <Esc>:ClangFormat<CR>a
"map Ctrl+q to force quit
nmap <C-q> :q!<CR>
"map Ctrl+q to force quit
nmap<C-o> :NERDTree<CR>
vnoremap <C-c> "+y
vnoremap <C-v> "+p
  • solved by putting set clipboard=unnamedplus Aug 7 '21 at 2:24
  • 1
    Please post an answer with what worked to solve the problem for you!
    – filbranden
    Aug 7 '21 at 4:03
  • Welcome to Vi and Vim! Please consider spending some time with the tour or help center. As filbranden says, answers belong in the answer box, not comments—even self-answers! You might also want to take a look at How to debug my vimrc to slim down the vimrc and identify what's actually relevant to your post; you can edit to include only relevant details and even use Markdown formatting.
    – D. Ben Knoble
    Aug 7 '21 at 21:37

solved by putting on my .bashrc

stty -ixon
  • that doesn't make any sense. clipboard=unnamedplus has nothing to do with using the Ctrl-C / Ctrl-V keys for copy and pasting. Aug 11 '21 at 6:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.