Re: sample ~/.vimrc

"Bruce Dubbs" ([email protected] via blfs-dev Mailing List) <[email protected]>
Newsgroups gmane.linux.lfs.beyond.devel
Message-ID <[email protected]>
On 5/30/25 3:24 PM, DJ Lucas ([email protected] via blfs-dev Mailing List) wrote:
> It annoys me as, for whatever reason, I cannot remember where to look and need to do 
> so after every break! :-)
> 
> From  ":h defaults" in modern vim:
> 
> Defaults without a .vimrc file
> ==================================================================
> If Vim is started normally and no user vimrc file is found, the
> $VIMRUNTIME/defaults.vim script is loaded.  This will set 'compatible' off,
> switch on syntax highlighting and a few more things.  See the script for
> details.  NOTE: this is done since Vim 8.0, not in Vim 7.4. (it was added in
> patch 7.4.2111 to be exact).
> 
> This should work well for new Vim users.  If you create your own .vimrc, it is
> recommended to add these lines somewhere near the top:
>          unlet! skip_defaults_vim
>          source $VIMRUNTIME/defaults.vim
> Then Vim works like before you had a .vimrc.
> Copying $VIMRUNTIME/vimrc_example.vim to your .vimrc is another way to do
> this. Alternatively, you can copy defaults.vim to your .vimrc and modify it
> (but then you won't get updates when it changes).
> ==================================================================
> 
> The .vimrc example in the book dates back to well before vim 7.4. I think these two 
> lines should probably be added to the default .vimrc in the book - per the 
> developers' recommendation. It will not matter for power users as the .vimrc that has 
> been developed over the past 10+ years is copied from machine to machine anyway. 
> Maybe add a note about the location of $VIMRUNTIME (or show the command so it doesn't 
> have to be updated when a new minor is released - ':echo $VIMRUNITME' works well 
> enough).

There are lots of things to set in vim.  Here is my config:

$ cat /etc/vimrc
" Begin /etc/vimrc

" Ensure defaults are set before customizing settings, not after
"source $VIMRUNTIME/defaults.vim
let skip_defaults_vim=1

set nocompatible
set backspace=2
syntax on

set nosmartindent

set expandtab
set tabstop=3
set shiftwidth=3
set laststatus=2
set background=dark
set ai
"set backup
set viminfo='20,\"50    " read/write a .viminfo file, don't store more
                         " than 50 lines of registers
set history=50          " keep 50 lines of command line history
set ruler
set hlsearch

set mouse=

augroup cprog
  " Remove all cprog autocommands
  au!

  " When starting to edit a file:
  "   For C and C++ files set formatting of comments and set C-indenting on.
  "   For other files switch it off. 

  "   Don't change the order, it's important that the line with * comes first. 

  autocmd FileType *      set formatoptions=tcql nocindent comments& 

  autocmd FileType c,cpp  set formatoptions=croql cindent 
comments=sr:/*,mb:*,el:*/,://
augroup END

" End /etc/vimrc


One problem I had was that the defaults were being run AFTER the configuration file. 
That overwrote my settings.  The default mouse setting was very irritating when using 
the center mouse button for pasting.

   -- Bruce

-- 
http://lists.linuxfromscratch.org/sympa/info/blfs-dev
Unsubscribe: See the above information page
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.