Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mappings on vim throwing an error (E10: \ should be followed by /, ? or &)

Tags:

vim

Hi I'm using MacVim 7.3 I'm following a PeepCode tutorial called smash into vim.

One of the topics is to assign various "mappings" (I think of them as shortcuts or aliases) for certain commands.

For example, here is part of my .vimrc file (see below) The help files say that is assigned as backslash (\) by default. However, when I enter command-line mode and type :\tt I get the following error:

E10: \ should be followed by /, ? or &

Any thoughts on what I'm doing wrong? I can tell that my .vimrc file is being used by macvim b/c I used the file to swap the semi-colon and colon bindings and now ; will cause the editor to enter command-line mode.

" Tab mappings.
map <leader>tt :tabnew<cr>
map <leader>te :tabedit
map <leader>tc :tabclose<cr>
map <leader>to :tabonly<cr>
map <leader>tn :tabnext<cr>
map <leader>tp :tabprevious<cr>
map <leader>tf :tabfirst<cr>
map <leader>tl :tablast<cr>
map <leader>tm :tabmove


" Controversial...swap colon and semicolon for easier commands
nnoremap ; :
nnoremap : ;

vnoremap ; :
vnoremap : ;
like image 395
user141146 Avatar asked Jan 22 '11 05:01

user141146


1 Answers

When you are mapping something like <leader>tt it does not work in command mode (invoked using :) but in normal mode.

So all you have to do is to type \tt without : and see what happens : a new tab should open hopefully.

Regarding the use of <leader> in defining a new mapping, the main interest is that, if you are not satisfied with the use of \, you can redefine the key the following way at the beginning of your .vimrc:

:let mapleader = ","

and you leader key will change in every subsequent mapping command : \tt becomes ,tt

Good luck on your way to become a proficient Vim user !

like image 94
Xavier T. Avatar answered Oct 01 '22 10:10

Xavier T.