Skip to content

Instantly share code, notes, and snippets.

@andrewshadura
Created May 15, 2026 09:03
Show Gist options
  • Select an option

  • Save andrewshadura/411af9ff4a376601c343387681c1fc86 to your computer and use it in GitHub Desktop.

Select an option

Save andrewshadura/411af9ff4a376601c343387681c1fc86 to your computer and use it in GitHub Desktop.
syntax on
""" disable visual bell
" set novisualbell
" set t_vb=
set visualbell t_vb=
set belloff=all
""" disable pager for spawned processes
"let $PAGER=''
""" list mode chars
if has("multi_byte")
set listchars=tab:▸\ ,nbsp:¬,eol:¶,extends:»,precedes:«,trail:•
else
set listchars=tab:>\ ,nbsp:~,eol:$,extends:>,precedes:<,trail:\
endif
""" pascal dialect we use is delphi/fpc
let pascal_delphi=1
let pascal_fpc=1
""" #!/bin/sh is POSIX, VIM assumes it is not :(
let g:is_posix=1
""" dunno what's that
set langmenu=none
""" expand tabs
set et
""" allow cursor movements to wrap
set ww=b,s,<,>
if has("gui_running")
set guioptions-=e
set guioptions-=T
set guioptions+=c
set guioptions-=L
set guioptions-=l
set guioptions-=R
set guioptions-=r
set ghr=0
set guicursor=n-v-c:block-Cursor/lCursor,ve:block-Cursor,o:hor50-Cursor,i-ci:block-Cursor/lCursor,r-cr:hor20-Cursor/lCursor,sm:block-Cursor,a:blinkoff0
set novb
set number
colorscheme desert
set guifont=Input\ 10
" set guifont=Monospace\ 10
else
set t_Co=256
colorscheme desert256
""" use mcedit's highlighting scheme
" source ~/.vimhilite
endif
" don’t automatically put selection into the clipboard
set clipboard=
""" c-f11 toggles relative line numbers
" nmap <c-f11> :exec &rnu? "se nu! nornu!" : ( &nu? "se rnu!" : "se nu!" )<CR>
""" use menus and mans
source $VIMRUNTIME/menu.vim
source $VIMRUNTIME/ftplugin/man.vim
""" use <tab> for menu over status bar
set wildmenu
set wcm=<Tab>
""" encodings menu
menu Encoding.koi8-r :e ++enc=koi8-r<CR>
menu Encoding.windows-1250 :e ++enc=cp1250<CR>
menu Encoding.windows-1251 :e ++enc=cp1251<CR>
menu Encoding.windows-1252 :e ++enc=cp1252<CR>
menu Encoding.iso-8859-1 :e ++enc=iso-8859-1<CR>
menu Encoding.iso-8859-2 :e ++enc=iso-8859-2<CR>
menu Encoding.cp866 :e ++enc=cp866<CR>
menu Encoding.utf-8 :e ++enc=utf8 <CR>
""" detect cp1251 automagically
"set fileencodings=utf-8,8bit-cp1251
set fileencodings=utf-8
""" map encoding menu on F8
" map <F8> :emenu Encoding.<TAB>
" nmap <F2> :wa<Bar>exe "mksession! " . v:this_session<CR>:so ~/sessions/
""" map <F2> <Esc>:w<CR>
map <F9> :emenu <TAB>
" map
""" use mouse
if has("mouse")
set mouse=a
set mousemodel=popup
set mousehide
if !has('nvim')
" set ttymouse=xterm2
endif
endif
""" wtf?
set hidden
""" autoindent
set autoindent
"set smartindent
au BufRead,BufNewFile *.todo.txt set filetype=todo
au BufRead,BufNewFile *.c set smartindent
au BufRead,BufNewFile *.cpp set smartindent
au BufRead,BufNewFile *.cxx set smartindent
au BufRead,BufNewFile *.h set smartindent
au BufRead,BufNewFile *.hpp set smartindent
au BufRead,BufNewFile *.java set smartindent
au BufRead,BufNewFile *.rb set smartindent
au BufRead,BufNewFile *.vala set syntax=cpp
""" indentation
set scrolljump=2
set scrolloff=2
set shiftwidth=4
set softtabstop=4
set tabstop=4
" autocmd BufReadPost * :DetectIndent
" let g:detectindent_preferred_expandtab = 1
" let g:detectindent_preferred_indent = 4
set foldmethod=indent
set nofoldenable
"""" x selection: ^C yanks to it, ^V pastes
"vmap <C-C> "*yi
"imap <C-V> <esc>"*gPi
""" x clipboard: ^C yanks to it, ^V pastes
vmap <C-C> "+yi
imap <C-V> <esc>"+gPi
set pastetoggle=<F7>
""" buffer switch on F6
map <F6> :bn<cr>
vmap <F6> <esc>:bn<cr>i
imap <F6> <esc>:bn<cr>i
map <S-F6> :bp<cr>
vmap <S-F6> <esc>:bp<cr>i
imap <S-F6> <esc>:bp<cr>i
""" show man on K
" nmap K b"zyw:exe "Man ".@z.""<CR>
""" <</>> un/indents the current selection/current line
vmap < <gv
vmap > >gv
""" statusline format
set statusline=%<%f%h%m%r\ %b\ %{&encoding}\ 0x%B\ \ %l,%c%V\ %P
set laststatus=2
""" completion dict setup
set complete=""
set complete+=.
set complete+=k
set complete+=b
set complete+=t
set modeline
""" highlight extra spaces
highlight ExtraWhitespace ctermbg=darkyellow guibg=darkyellow
au BufWinEnter * match ExtraWhitespace /\s\+$/
au InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
au InsertLeave * match ExtraWhitespace /\s\+$/
au BufWinLeave * call clearmatches()
" nmap ,h :exec synIDattr(synIDtrans(hlID("ExtraWhitespace")), "bg") == -1 ? "highlight ExtraWhitespace ctermbg=darkyellow guibg=darkyellow" : "highlight ExtraWhitespace NONE" <CR>
""" detect filetypes
filetype plugin indent on
""" hg menu (have I ever used it?)
" source /usr/share/doc/mercurial/examples/vim/hg-menu.vim
"""""" don't jump on *
"""nnoremap * *N
"""vnoremap * y :execute ":let @/=@\""<CR> :execute "set hlsearch"<CR>
nnoremap <C-F8> :set hlsearch<CR>
" Override the 'ignorecase' option if the search pattern contains upper case characters
set smartcase
" Prevent accidental editing of patch .orig files
autocmd BufRead *.orig set readonly
" set spell
set spelllang=en_gb
" set spelllang=ru_yo,en_gb
nnoremap ; :
nmap <silent> ' F"r'f"r'
nmap <silent> " F'r"f'r"
if has('cscope')
set cscopetag cscopeverbose
if has('quickfix')
set cscopequickfix=s-,c-,d-,i-,t-,e-,f0,g0
endif
endif
nmap <F4> :TagbarToggle<Enter>
imap <F4> <C-o>:TagbarToggle<Enter>
vmap <F4> <Esc>:TagbarToggle<Enter>gv
nmap <C-Up> :tabprevious<Enter>
imap <C-Up> <Esc>:tabprevious<Enter>
vmap <C-Up> <Esc>:tabprevious<Enter>
nmap <C-Down> :tabnext<Enter>
imap <C-Down> <Esc>:tabnext<Enter>
vmap <C-Down> <Esc>:tabnext<Enter>
" nmap <C-Up> :cprevious<Enter>
" imap <C-Up> <Esc>:cprevious<Enter>
" vmap <C-Up> <Esc>:cprevious<Enter>
"
" nmap <C-Down> :cnext<Enter>
" imap <C-Down> <Esc>:cnext<Enter>
" vmap <C-Down> <Esc>:cnext<Enter>
if &term =~ "screen"
map <esc>[1;5D <C-Left>
map! <esc>[1;5D <C-Left>
map <esc>[1;5C <C-Right>
map! <esc>[1;5C <C-Right>
endif
autocmd QuickFixCmdPost * copen
set directory=~/.local/share/vim//
" nmap ,s :cs find s <C-r><C-w><Enter>
let g:airline_powerline_fonts=1
" let g:airline#extensions#tabline#enabled=1
let g:airline#extensions#wordcount#enabled=0
function! SetupEnvironment()
let l:path = expand('%:p')
if l:path =~ '/home/andrewsh/linux'
setlocal noexpandtab tabstop=8 list
elseif l:path =~ '/home/andrewsh/projects'
" setlocal tabstop=4 shiftwidth=4 noexpandtab
endif
if l:path =~ '/home/andrewsh/.config/fontconfig'
if expand('%:e') == 'conf'
set syntax=xml
endif
endif
endfunction
autocmd! BufReadPost,BufNewFile * call SetupEnvironment()
let g:vim_markdown_preview_pandoc=1
let g:vim_markdown_preview_use_xdg_open=1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment