Saturday, November 3, 2012

Re: Opening multiple files thru command line

On 2012-11-03, analogsix wrote:
> I have a basic .vimrc and .gvimrc files that setup my options for
> my programming environment. I expect these files to get
> automatically sourced for all files in the arguments list of the
> vim -o[N] files command. Also, the .vimrc and .gvimrc files source
> a systemverilog.vim syntax file.
>
> However, when I open multiple files through the command line, my
> settings don't appear to be sourced in all windows. For example,
> one window (the active one) would have the :set nowrap option but
> the other two won't. Also, the other windows are not syntax color
> coded as I would expect.
>
> Can you assist?

The .vimrc and .gvimrc files are sourced once when you start Vim.
Their settings apply to all subsequently opened files unless those
settings are overridden, for example by a filetype plugin.

If some of your settings are not being applied in all windows, then
my guess is the same as Marcin's, that you are using :setlocal
instead of :set in your .vimrc.

To find out where a setting was last made, you can query its value
like this:

:verbose set wrap?

Settings that are to be applied to each file as it is opened
according to its file type are executed via Vim's filetype
mechanism. See ":help usr_43.txt" for an introduction.

Any setting you want to apply to all files opened by Vim should be
set using :set in your .vimrc while any setting you want to apply
only to files of a specific type should be set using :setlocal in a
filetype plugin, usually ~/.vim/after/ftplugin/<filetype>.vim, as
explained under ":help ftplugin-overrule", paragraph 3.

> Also, the .vimrc and .gvimrc files source a systemverilog.vim
> syntax file.

Don't source filetype-specific files in your ~/.vimrc. Put
systemverilog.vim in ~/.vim/after/ftplugin or ~/.vim/ftplugin and
put the "filetype plugin on" command in your ~/.vimrc instead.

It sounds like you may think that ~/.vimrc is the configuration file
for vim while ~/.gvimrc is the configuration file for gvim. This is
not true. ~/.vimrc is sourced by both vim and gvim. ~/.gvimrc is
sourced only by gvim and is intended to contain only GUI-related
settings. See

:help gvimrc
:help startup

for more details.

> Also, the other windows are not syntax color coded as I would
> expect.

If you have

filetype plugin on
syntax on

in your ~/.vimrc, your systemverilog filetype is being detected, and
the syntax/systemverilog.vim file exists in $VIMRUNTIME or ~/.vim,
then syntax coloring should work. See ":help usr_06.txt" for more
on this.

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

No comments:

Post a Comment