📜 ⬆️ ⬇️

.vimrc, which is always with me

My .vimrc is more than eight years old. He remembers the times of PentiumII, Debian Potato, and gcc so ancient that I don’t even remember its version. It developed from the fifth version of Vim, acquired useful fragments and got rid of unnecessary ones. And suddenly I wanted to share with you its contents. I will not show the whole file yet, just go through some, in my opinion, interesting moments.

Safety and availability

Last time I keep it in svn on one of my hosts. On the machine I need, I just get it out of the repository and work:
$ cd ~
$ svn ls svn+ssh://svn.example.com/var/svn/repo/trunk/profile ./
.vimrc
vimrc
$ svn co svn+ssh://svn.example.com/var/svn/repo/trunk/profile ./

Once and for all we add convenient settings

Adjust the number of characters of spaces that will replace \ t
set tabstop = 4
set shiftwidth = 4
set smarttab
set et - enable default autochange

set wrap - ask Vim to wrap long lines

set ai - enable auto-indents for new lines
set cin - enable C style indents
')
Next, set up the search and highlighting of the search results and matching brackets
set showmatch
set hlsearch
set incsearch
set ignorecase

set lz - lazy redrawing the screen when executing scripts

Show tabs at the beginning of the line with dots
set listchars = tab: ··
set list

The order of the encoding and file format

set ffs = unix, dos, mac
set fencs = utf-8, cp1251, koi8-r, ucs-2, cp866

Interaction and interface elements

I often highlight the contents of the screen with the mouse in Putty, but intercepting the mouse in Vim sometimes bothers me. Disable the functionality outside the graphics mode:
if! has ('gui_running')
set mouse =
endif

Getting rid of the menu and toolbar:
set guioptions- = T
set guioptions- = m

Different graphic systems use different fonts:
if has ('gui')
colorscheme darkblue
if has ('win32')
set guifont = Lucida_Console: h12: cRUSSIAN ::
else
set guifont = Terminus \ 14
endif
endif

We are trying to take the largest possible space on the screen. As usual, in different ways on different systems:
if has ('gui')
if has ('win32')
au GUIEnter * call libcallnr ('maximize', 'Maximize', 1)
elseif has ('gui_gtk2')
au GUIEnter *: set lines = 99999 columns = 99999
endif
endif

Again, build systems for different platforms can be redefined:
if has ('win32')
set makeprg = nmake
compiler msvc
else
set makeprg = make
compiler gcc
endif

: wq

Source: https://habr.com/ru/post/65518/


All Articles