Mapping key to make new vertical window in Vim

0

This is really odd. Here's the key mapping from my .vimrc:

noremap <C-n> :vert new<CR>

The expected behaviour when I press CTRL-n is that it opens a vertical window but it somehow opens a horizontal window on top of the current.

The problem only arises for the mappings. When I try :vert new from Vim, I get what I want, a new vertical window.

I have also tried :vnew and :vsplit new, they all work fine when I manually initiate them. Does not work with CTRL-n.

maverick97

Posted 2014-06-10T18:18:37.390

Reputation: 3

Please share your complete version ($ vim --version) and the content of your ~/.vimrc. – romainl – 2014-06-10T19:31:30.427

From $ vim --version:

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Aug 12 2013 00:23:33)

This is my .vimrc. Check out line 146.

– maverick97 – 2014-06-11T04:46:10.567

I asked for your complete version. – romainl – 2014-06-11T05:19:27.107

Answers

1

This line:

noremap  <C-N>    :new<CR>

overrides the previous one because <C-N> is the same as <C-n>.

Choose your mappings more wisely.

romainl

Posted 2014-06-10T18:18:37.390

Reputation: 19 227

Thanks, it worked. :) Then, how do I map keys that are capitalized? I tried something like <C><S>n and <C>N. Didn't work, how do you map it? – maverick97 – 2014-06-11T07:51:39.420

You don't. <C-S-n> would be the canonical representation of Ctrl+N (IIRC) but Vim won't make a difference between Ctrl+N and Ctrl+n anyway. See :help ctrl-{char}. – romainl – 2014-06-11T08:02:49.780