You are not logged in.

#1 2017-06-13 20:25:36

FlowIt
Member
Registered: 2014-10-25
Posts: 243

[Solved] [vim] rebind visual block

I try to mimic what the mswin script does, but since I don't need all of those options and since I am a bit hesitant of changing more behaviour than I actually need I decided to only use those few lines in my vimrc. All I need is copy and paste to and from the system clipboard. Copying only has to work in visual mode, inserting should work in normal, visual and insert mode. So Ctrl+V gets rebinded and I need a new key combination to start a visual block, for which mswin uses Ctrl-Q. However, with the following lines I cannot start a visual block, copying and pasting works fine. This is my full vimrc:

set nocompatible                " Use Vim defaults instead of 100% vi compatibility
set backspace=indent,eol,start  " more powerful backspacing

" Now we set some defaults for the editor
set history=50                  " keep 50 lines of command line history
set ruler                       " show the cursor position all the time

" Suffixes that get lower priority when doing tab completion for filenames.
" These are files we are not likely to want to edit or read.
set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.brf,.cb,.ind,.idx,.ilg,.inx,.out,.toc,.png,.jpg

" simple copy/paste with system clipboard
map <C-C> "+y
map <C-V> "+P
cmap <C-V> <C-R>+
imap <C-V> <C-r><C-P>+
noremap <C-Q> <C-V>

" appearance settings
set t_Co=256
" colorscheme desert
" autocmd ColorScheme * highlight LineNr guifg=#AAAAAA

" general options
syntax on
set encoding=utf-8
set fileencoding=utf-8
set guioptions-=T
set wrap
set linebreak
set nolist
set nu!
set tabstop=2 softtabstop=0 expandtab shiftwidth=2 smarttab

Last edited by FlowIt (2017-06-19 09:36:25)

Offline

#2 2017-06-14 12:26:34

zerophase
Member
Registered: 2015-09-03
Posts: 239

Re: [Solved] [vim] rebind visual block

I think this is all you need if you install gvim.

map <leader>p :set paste<CR>o<esc>"*]p:set nopaste<cr>

Offline

#3 2017-06-14 14:15:11

FlowIt
Member
Registered: 2014-10-25
Posts: 243

Re: [Solved] [vim] rebind visual block

Adding this line to my vimrc does not allow using Ctrl+Q for visual block.
My question was about console vim, altough I didn't say that explicitly. I just tried gvim, without your suggestion, and there Ctrl+Q works, just not in console vim.
In case it is important: I am using termite as my terminal.

Last edited by FlowIt (2017-06-14 14:15:50)

Offline

#4 2017-06-15 21:05:12

zerophase
Member
Registered: 2015-09-03
Posts: 239

Re: [Solved] [vim] rebind visual block

It works for me in terminal, for pasting in. I can't remember where I configured the copy in my vimrc. Here's my vimrc. I think it's setting the runtime to archlinux.vim that does it.

https://gist.github.com/Zerophase/3e7b8 … 65dd1b4e43

Offline

#5 2017-06-18 20:09:16

FlowIt
Member
Registered: 2014-10-25
Posts: 243

Re: [Solved] [vim] rebind visual block

No it's not archlinux.vim that does it. Copying and pasting WORKS, it's the visual block that doesn't. Without my modifications, Ctrl+V will start a visual block, after my modifications Ctrl+V will paste. So I tried to rebind it to Ctrl+Q, but that does nothing. I just updated my vimrc a little bit to match exactly the mappings mswin does:

vnoremap <C-C> "+y
map <C-V> "+gP
cmap <C-V> <C-R>+
"imap <C-V> <C-r><C-P>+
noremap <C-Q> <C-V>

Commenting the imap line out does not make a difference, I use it to paste also in insert mode.

Offline

#6 2017-06-19 08:48:01

stupidus
Member
Registered: 2012-02-27
Posts: 124

Re: [Solved] [vim] rebind visual block

Your configuration is working for me in vim. If it is working for you in gvim, I assume that your terminal emulator is the problem. Which one are you using?

EDIT: I just saw that you are using termite. That is the same that I am using. Are there any other settings in your .vimrc? When I tested it, I had only the few lines that you posted above in my .vimrc.
Are there any weird settings in your termite configuration?

Last edited by stupidus (2017-06-19 08:51:00)

Offline

#7 2017-06-19 09:36:08

FlowIt
Member
Registered: 2014-10-25
Posts: 243

Re: [Solved] [vim] rebind visual block

I just tested it in gvim and there my config works, but not in console vim. I tried both termite, lxterminal and xterm (the latter two both with stock configuration) and it doesn't work in console vim. And yes, the lines I posted above are my only vim configuration.
Edit: The hint to try it in gvim led me to https://stackoverflow.com/questions/218 … -vim-gnome
Adding stty start undef solved it for me.

Offline

Board footer

Powered by FluxBB