> On 19/05/11 11:36 PM, cyboman wrote:
>> i'm continuously making additions to my _vimrc file and sometimes need
>> to re-source the file. i have a lot of mappings in the file so every
>> time i re-source it i get errors saying that the given mapping already
>> exists. does anybody know if there is a way to source _vimrc without
>> showing all those errors?
>
> I don't see any problem with mappings being redefined. I can do
>
> :map a b
>
> and then the same again with no error. Nor can I find an error message
> about mappings already existing in the help, so I don't think I've just
> turned it off, though perhaps I have.
>
> If it's commands and functions, you can redefine those by adding a ! so
> you have function! and command!. To deal with autocommands, you should
> use autocommand groups and clear them, e.g.:
>
> augroup MyAutocommands
> au!
> au BufRead * do something
> augroup END
>
> That should take care of most things and allow you to source your vimrc
> multiple times. I do it often with mine, so it's definitely possible.
>
> Ben.
>
>
Of course the vimrc is not meant to be sourced more than once, and if
yours (like mine) sources the vimrc_example.vim it might quite well fail
at that point.
When I make small changes in the vimrc (add a mapping, say, or change an
option value), I make the changes in the vimrc and apply them manually
in the running Vim (maybe by yanking the line, pasting it on the
command-line with Ctrl-R quote, maybe editing away ^M [end-of-line] and
^I [tab, usually replaced by a space] and finally hitting Enter). For
bigger changes (a new function, or even just a new code snippet with an
:if clause) I prefer restarting Vim.
You could also use :mksession to restart Vim where you left it, see
:help :mksession
:help 'sessionoptions'
:help -S
You can use -S without :mksession if you write your own "startup script"
to open your windows and tabs (mine don't change much, so I have a
fairly stable handwritten session file); it may be much simpler than a
generated session file, and save quite some code duplication between it
and the vimrc.
Best regards,
Tony.
--
Do molecular biologists wear designer genes?
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
No comments:
Post a Comment