Alex Ironside
Alex Ironside

Reputation: 5039

Remaping [ to { in vim

I started working with VIM and I'm trying to configure it. Currently I want to remap [ and {

So if I press [ I get { without mashing shift. Right now I have it like this:

inoremap [ {                   
inoremap ] } 

But it doesn't work. It just keeps on putting the [. What am I doing wrong and how can I fix it?

I don't know if it matters but I'm using the auto-pairs plug-in.

EDIT Just in case someone just wants to use it without any contiguration, here you go

ino " ""<left>
ino ' ''<left>
ino ( ()<left>
ino [ {}<left>
ino { []<left>
ino {<CR> {<CR>}<ESC>0
ino {;<CR> {<CR>};<ESC>0

Taken from Automatic closing brackets for Vim and slightly edited.

Upvotes: 2

Views: 88

Answers (1)

dlmeetei
dlmeetei

Reputation: 10371

Looks like you have turned on set paste.
if set paste? is showing paste as result. You can disable it by

:set nopaste

and try again.

More details at help paste and you may like help pastetoggle also.

Upvotes: 2

Related Questions