Skip to content

Instantly share code, notes, and snippets.

@CHERTS
Created January 26, 2024 06:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CHERTS/51d0614d99304e934842ca9cf926e5d3 to your computer and use it in GitHub Desktop.
Save CHERTS/51d0614d99304e934842ca9cf926e5d3 to your computer and use it in GitHub Desktop.
My .vimrc file
vnoremap :w !xsel -b
" Make backspace delete lots of things
" set backspace=indent,eol,start
" Enable syntax highlighting
syntax on
" Enable line highlight
set cursorline
" Try to show at least three lines and two columns of context when
" scrolling
set scrolloff=3
set sidescrolloff=2
" Set tab to 4 spaces
set tabstop=4
set shiftwidth=4
set smarttab
" Enable autocorrect by default
set et
" Wrap string
set wrap
" Enable auto indentation for new lines
set ai
" C indent style
set cin
" Highlight matching parens
set showmatch
" Search options: incremental search, do clever case things, highlight
" search
set incsearch
set ignorecase
set infercase
set hlsearch
" Lazy screen redrawing when executing scripts
set lz
" Order of using encodings and file format
set ffs=unix,dos,mac
set fencs=utf-8,cp1251,koi8-r,ucs-2,cp866
" Remove menu and toolbar
set guioptions-=T
set guioptions-=m
" When copy-pasting, all indents are correctly set
set paste
set pastetoggle=
" Color scheme and fonts
if has('gui')
colorscheme darkblue
if has('win32')
set guifont=Lucida_Console:h12:cRUSSIAN::
else
set guifont=Terminus\ 14
endif
endif
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
if has('win32')
set makeprg=nmake
compiler msvc
else
set makeprg=make
compiler gcc
endif
" Status line format
set statusline=%F%m%r%h%w\ [FORMAT=%{&ff}]\ [TYPE=%Y]\ [ASCII=\%03.3b]\ [HEX=\%02.2B]\ [POS=%04l,%04v][%p%%]\ [LEN=%L]
set laststatus=2
" Enable modelines only on secure vim versions
if (v:version == 603 && has("patch045")) || (v:version > 603)
set modeline
else
set nomodeline
endif
" Content creation
augroup content
autocmd BufNewFile *.php 0put = '?>'|
\ 0put = '// vim: set sw=4 sts=4 et foldmethod=syntax :'|
\ 0put = '<?'|
\ set sw=4 sts=4 et tw=80 |
\ norm G
autocmd BufNewFile *.php5 0put = '?>'|
\ 0put = '// vim: set sw=4 sts=4 et foldmethod=syntax :'|
\ 0put = '<?'|
\ set sw=4 sts=4 et tw=80 |
\ norm G
autocmd BufNewFile *.rb 0put ='# vim: set sw=2 sts=2 et tw=80 :' |
\ 0put ='#!/usr/bin/env ruby' | set sw=2 sts=2 et tw=80 |
\ norm G
autocmd BufNewFile *.sh 0put ='# vim: set sw=4 sts=4 et tw=80 :' |
\ 0put ='#!/bin/bash' | set sw=4 sts=4 et tw=80 |
\ norm G
autocmd BufNewFile *.pl 0put ='# vim: set sw=4 sts=4 et tw=80 :' |
\ 0put ='#!/usr/bin/perl' | set sw=4 sts=4 et tw=80 |
\ norm G
autocmd BufNewFile *.hh 0put ='/* vim: set sw=4 sts=4 et foldmethod=syntax : */' |
\ 1put ='' | call MakeIncludeGuards() |
\ 5put ='#include \"config.h\"' |
\ set sw=4 sts=4 et tw=80 | norm G
autocmd BufNewFile *.cc 0put ='/* vim: set sw=4 sts=4 et foldmethod=syntax : */' |
\ 1put ='' | 2put ='' | call setline(3, '#include "' .
\ substitute(expand("%:t"), ".cc$", ".hh", "") . '"') |
\ set sw=4 sts=4 et tw=80 | norm G
augroup END
" Press F1 to on/off line number
imap <F1> <Esc>:set<Space>nu!<CR>a
nmap <F1> :set<Space>nu!<CR>
" Вкл/выкл отображения найденных соответствий
imap <S-F1> <Esc>:set<Space>hls!<CR>a
nmap <S-F1> :set<Space>hls!<CR>
" Выход по F12
imap <F12> <Esc>:qa<CR>
nmap <F12> :qa<CR>
" Сохранение по F2
imap <F2> <Esc>:w<CR>a
nmap <F2> :w<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment