开发者

vim mapping for editing vimrc not working?

开发者 https://www.devze.com 2023-02-25 17:29 出处:网络
Trying to do the following in .vimrc: \" Define map leader let mapleader = \",\" let g:mapleader = \",\"

Trying to do the following in .vimrc:

" Define map leader
let mapleader = ","
let g:mapleader = ","

" Fast editing of the .vimrc
map <leader>e :e! ~/.vimrc<cr>

(From http://amix.dk/vim/vimrc.html)

but whenever I run the command by trying to type :,e I get this error message:

E481: No range allowed

I'm new to vim (currently running through the Nettuts video series) and this is driving me nuts... what am I doing wrong? I've quit and relaunched vim several times, no change.

I've also tried (out of the video tutorials) this:

nmap ,ev :tabedit $MYVIMRC<cr>

... which gives me this: E492: Not an editor command: ,ev

The command does show up when I run :map:

n  ,ev           :tabedit $M开发者_JAVA技巧YVIMRC<CR>

Help!


Just type ,e instead of :,e.


If you want it as an ex : command, you may use cmap instead of map. See :help cmap

" Should work:
cmap <leader>e e! ~/.vimrc<cr>

But as you've defined it, you should be able to run it with simply ,e


I use:

nmap <silent> ,ev :e $MYVIMRC<CR>

you can also adjust that mapping with :so $MYVIMRC<CR> so that it sources your vimrc without having to quit Vim for changes to take effect (you obviously have to use something other than ,ev).

0

精彩评论

暂无评论...
验证码 换一张
取 消