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 p开发者_高级运维art 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 : ;
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 !
You have two problems: one is that you are using map
and then remap semicolon, so map <leader>tt :tabnew<CR>
tries to execute ;tabnew<CR>
(;
repeats previous t/T/f/F motion, ta
moves cursor to next a
, n
tries to repeat previous search and so on) and it won't work. You should use noremap
where possible, do not use map
without nore
unless you know what you are doing (and I also suggest changing noremap
to nnoremap
here: I don't think you need to change tabs from visual and, especially, operator-pending modes). Second problem is that noremap
remaps commands in normal mode, so you need to type \tt
, not :\tt
or ;\tt
.
精彩评论