On 2011-09-09, Joachim Hofmann wrote:
> Hello,
>
> I am editing a *.rb (ruby) buffer.
> Then I open a command line history window with q: , search for a
> command and execute it.
> The command line window closes and vim is back in the *.rb buffer.
>
> Problem: my settings for ruby are now still overwritten with my settings
> for vim.
>
> I have settings in my _vimrc for entering and leaving ruby and vim files
> like this:
>
> ...
> autocmd FileType vim so $HOME/vimstuff/mymacs/vimenter.vim
> autocmd FileType ruby so $HOME/vimstuff/mymacs/rubyenter.vim
> autocmd BufEnter,BufRead,WinEnter *.rb so
> $HOME/vimstuff/mymacs/rubyenter.vim
> ...
>
> Normally setting the ruby and vim settings work.
> It seems that in this special case (using q:) the vim settings are set
> because of probably the command line window is of f vim;
> but the ruby settings are not sourced again when going back to the ruby
> file.
>
> Any ideas how I can get my ruby settings back; or can debug it?
It would help to know what is in $HOME/vimstuff/mymacs/vimenter.vim,
but even without that, my guess is that your vimenter.vim and
rubyenter.vim scripts make global settings rather than buffer-local
settings. For example, you are probably using :set rather than
:setlocal to make option settings.
That's also why you seem to find it necessary to use this:
autocmd BufEnter,BufRead,WinEnter *.rb so
$HOME/vimstuff/mymacs/rubyenter.vim
in addition to the FileType autocommands. You shouldn't need to do
that. You should only need to make most settings once when each
buffer is opened, not each time it's entered.
Further, you can simplify your _vimrc file by eliminating those
autocommands altogether and simply moving
$HOME/vimstuff/mymacs/vimenter.vim to
$HOME/vimfiles/after/ftplugin/vim.vim and
$HOME/vimstuff/mymacs/rubyenter.vim to
$HOME/vimfiles/after/ftplugin/ruby.vim.
See
:help setlocal
:help local-options
:help ftplugin
HTH,
Gary
--
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