In my vimrc I have a shortcut for opening a vertical split:
let mapleader = ','
map <leader>v :vsplit<CR> " ,v for vsplit
map <leader>s :split<CR> " ,s for split
This has been working fine for months, but recently it's started misbehaving: almost every time I try to split the window, it does split but then changes a load of text at the cursor and leaves itself in insert mode.
Here's an example:
before split: const queryValidation
after split: plit", n
All that I did was hit ,v which has been working fine until recently. I can't work out why this is happening now. My vim version is 7.4.2109.
(This doesn't happen if I just use :vsplit)
map <leader>s :split<CR>| " ,s for split. Note the|. – Antony Aug 08 '16 at 14:06:vsplitand:splitalready have normal mode commands:<C-w>vand<C-w>s. No need to waste keys on redundant shortcuts. – romainl Aug 08 '16 at 14:39<C-w>vis a lot more awkward for me to type than,v. – GTF Aug 08 '16 at 19:21"in a mapping, it will typically imply the normal mode key", which indicates a register. For example, the following map will ensure thatdddoes not add to the most recent register, but instead save to the "black hole"-register:nnoremap dd "_dd. The point is, since"is a reasonable part of the right-hand side of a map, it can NOT be used to start a comment. This explains why the comments screw up your mapping, and why it works when you remove them. – Karl Yngve Lervåg Aug 09 '16 at 06:41"comment. I'm not sure why it seemed to work before but Karl's explaination is totally right. – statox Aug 09 '16 at 07:14