Last active
January 21, 2021 15:32
-
-
Save mttmantovani/8c76882dc21aef0304a811387b43c948 to your computer and use it in GitHub Desktop.
Vim configuration file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" VIM configuration file | |
" author: mattia | |
" Last modified: Thu Jan 21, 2021 04:30PM | |
"{{{ Basic | |
syntax on | |
set showmatch | |
set number | |
set nocompatible | |
set bs=2 | |
set encoding=utf-8 | |
set shell=/bin/bash | |
set noswapfile | |
filetype on | |
set wildmenu | |
set ruler | |
set showcmd | |
set complete=k | |
set completeopt+=longest | |
set confirm | |
set mouse=a | |
set visualbell | |
colorscheme default | |
if has("gui_running") | |
if has("macunix") | |
colorscheme macvim | |
set guifont=Monaco:h16 | |
else | |
set guifont=Monaco\ 12 | |
endif | |
set lines=160 columns=100 | |
endif | |
"}}} | |
"{{{ Indenting, Folding, Wrapping | |
set tabstop=4 | |
set shiftwidth=4 | |
set softtabstop=4 | |
set expandtab | |
set autoindent | |
set nosmartindent | |
set nocindent | |
set foldenable | |
set foldmethod=marker | |
set nostartofline | |
set colorcolumn=80 | |
set linebreak | |
autocmd FileType make setlocal noexpandtab | |
autocmd FileType markdown setlocal tw=79 | |
autocmd FileType tex setlocal tw=79 | |
set fo=jq1 | |
"}}} | |
"{{{ Searching | |
set hlsearch | |
set incsearch | |
set ignorecase | |
set smartcase | |
set laststatus=2 | |
set ruler | |
set showmode | |
"}}} | |
"{{{ Set up status line | |
fun! <SID>SetStatusLine() | |
let l:s1="%-3.3n\\ %f\\ %h%m%r%w" | |
let l:s2="[%{strlen(&filetype)?&filetype:'?'},%{&encoding},%{&fileformat}]" | |
let l:s3="%=\\ 0x%-8B\\ \\ %-14.(%l,%c%V%)\\ %<%P" | |
execute "set statusline=" . l:s1 . l:s2 . l:s3 | |
endfun | |
set laststatus=2 | |
call <SID>SetStatusLine() | |
"}}} | |
"{{{ Miscellaneous & Plugins | |
"filetype plugin on | |
filetype indent on | |
"let g:tex_flavor = 'latex' | |
"let g:Tex_MultipleCompileFormats = 'pdf' | |
"let g:Tex_DefaultTargetFormat = 'pdf' | |
"let g:Tex_ViewRule_pdf = 'evince' | |
"let g:Tex_GotoError=0 | |
"}}} | |
"{{{ Write timestamp to file when saved | |
" If buffer modified, update any 'Last modified: ' in the first 20 lines. | |
" 'Last modified: ' can have up to 10 characters before (they are retained). | |
" Restores cursor and window position using save_cursor variable. | |
function! LastModified() | |
if &modified | |
let save_cursor = getpos(".") | |
let n = min([20, line("$")]) | |
keepjumps exe '1,' . n . 's#^\(.\{,10}Last modified: \).*#\1' . | |
\ strftime('%a %b %d, %Y %I:%M%p') . '#e' | |
call histdel('search', -1) | |
call setpos('.', save_cursor) | |
endif | |
endfun | |
autocmd BufWritePre * call LastModified() | |
"}}} | |
"{{{ Key bindings | |
map > >gv | |
map < <gv | |
"}}} | |
"{{{ Set up syntax for some extensions | |
au BufNewFile,BufRead *.pgf set syntax=tex | |
au BufNewFile,BufRead *.pgf set filetype=tex | |
au BufNewFile,BufRead *.tikz set filetype=tex | |
au BufNewFile,BufRead *.tikzstyles set syntax=tex | |
au BufNewFile,BufRead *.tikzstyles set filetype=tex | |
au BufNewFile,BufRead Snakefile set syntax=snakemake | |
au BufNewFile,BufRead *.snake set syntax=snakemake | |
"}}} | |
"{{{ AutoDark mode (macOS) | |
if has("macunix") | |
if exists('g:AutoDarkLoaded') || &cp | |
finish | |
end | |
let g:AutoDarkLoaded = 1 | |
if !exists('##OSAppearanceChanged') && has("gui_running") | |
echomsg "AutoDark requires MacVim Snapshot 160 or later." | |
finish | |
end | |
func! s:ChangeBackground() | |
if (v:os_appearance) | |
set background=dark | |
else | |
set background=light | |
endif | |
redraw! | |
endfunc | |
augroup AutoDark | |
autocmd OSAppearanceChanged * call s:ChangeBackground() | |
augroup END | |
end | |
"}}} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment