Skip to content

Instantly share code, notes, and snippets.

@mitliagkas
Created August 28, 2014 21:18
Show Gist options
  • Save mitliagkas/b8b7a01e780399023658 to your computer and use it in GitHub Desktop.
Save mitliagkas/b8b7a01e780399023658 to your computer and use it in GitHub Desktop.
Vim configuration
" All system-wide defaults are set in $VIMRUNTIME/debian.vim (usually just
" /usr/share/vim/vimcurrent/debian.vim) and sourced by the call to :runtime
" you can find below. If you wish to change any of those settings, you should
" do it in this file (/etc/vim/vimrc), since debian.vim will be overwritten
" everytime an upgrade of the vim packages is performed. It is recommended to
" make changes after sourcing debian.vim since it alters the value of the
" 'compatible' option.
" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim
" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'. Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
"set compatible
" Vim5 and later versions support syntax highlighting. Uncommenting the
" following enables syntax highlighting by default.
if has("syntax")
syntax on
endif
" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
"set background=dark
" Uncomment the following to have Vim jump to the last position when
" reopening a file
"if has("autocmd")
" au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
"endif
" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
"if has("autocmd")
" filetype plugin indent on
"endif
" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
"set showcmd " Show (partial) command in status line.
"set showmatch " Show matching brackets.
"set ignorecase " Do case insensitive matching
"set smartcase " Do smart case matching
"set incsearch " Incremental search
"set autowrite " Automatically save before commands like :next and :make
"set hidden " Hide buffers when they are abandoned
"set mouse=a " Enable mouse usage (all modes)
" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
source /etc/vim/vimrc.local
endif
" REQUIRED. This makes vim invoke Latex-Suite when you open a tex file.
filetype plugin on
" IMPORTANT: win32 users will need to have 'shellslash' set so that latex
" can be called correctly.
set shellslash
" IMPORTANT: grep will sometimes skip displaying the file name if you
" search in a singe file. This will confuse Latex-Suite. Set your grep
" program to always generate a file-name.
set grepprg=grep\ -nH\ $*
" OPTIONAL: This enables automatic indentation as you type.
filetype indent on
" OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to
" 'plaintex' instead of 'tex', which results in vim-latex not being loaded.
" The following changes the default filetype back to 'tex':
let g:tex_flavor='latex'
" Mine
"
set number
set scrolloff=3
set cmdheight=2
set nowrap
set sidescrolloff=7
set tabstop=2
set shiftwidth=2
runtime! ftplugin/man.vim
set showmatch
set fileencodings=ucs-bom,utf-8,default,iso-8859-15,iso-8859-7,windows1253,latin1
" LaTeX Suite
" IMPORTANT: grep will sometimes skip displaying the file name if you
" " search in a singe file. This will confuse latex-suite. Set your grep
" " program to alway generate a file-name.
set grepprg=grep\ -nH\ $*
" Create a skeleton m file using the function prototype that is the current
" line.
function MatSkell()
let s:line = getline(".")
let s:output = system("~/.vim/matlabSkell.rb \'" . s:line . "\'")
:execute ":e " . s:output
endfunction
map #6 :call system("ctags -R --exclude='.*'")<CR>
"Latex stuff
let g:Tex_Com_bibitem = "\\bibitem{<++>}\n<+names+>,\n``<+title+>'',\n{\\it <+source+>},\n<+sourcedetails+>, <+year+>."
au BufWritePost *.tex silent call Tex_CompileLatex()
"au BufWritePost *.tex silent call Tex_RunLaTeX()
au BufWritePost *.tex silent !pkill -USR1 xdvi.bin
"au BufWritePost *.tex silent !xpdf -remote vim -reload
au BufWritePost *.tex silent redraw
let g:Tex_CompileRule_dvi = 'latex -src-specials -interaction=nonstopmode $*'
let g:Tex_ViewRule_dvi = 'xdvi -hushstdout 2>/dev/null'
""" PDF through DVI
"let g:Tex_FormatDependency_pdf = 'dvi,pdf'
""let g:Tex_CompileRule_pdf = 'dvipdf $*.dvi'
""let g:Tex_CompileRule_pdf = 'dvipdf $*.dvi; xpdf -remote vim -reload -raise'
"let g:Tex_CompileRule_pdf = 'dvipdfm $*.dvi; xpdf -remote vim -reload -raise'
"let g:Tex_ViewRule_pdf = 'xpdf -remote vim -q'
""" DIRECT to PDF
let g:Tex_FormatDependency_pdf = 'pdf'
let g:Tex_CompileRule_pdf = 'pdflatex $*.tex; xpdf -remote vim -reload -raise'
let g:Tex_ViewRule_pdf = 'xpdf -remote vim -q'
"let g:Tex_ViewRule_pdf = 'xpdf -remote 127.0.0.1 2>/dev/null'
noremap <silent> <Leader>w :call ToggleWrap()<CR>
function ToggleWrap()
if &wrap
echo "Wrap OFF"
setlocal nowrap
set virtualedit=all
silent! nunmap <buffer> <Up>
silent! nunmap <buffer> <Down>
silent! nunmap <buffer> <Home>
silent! nunmap <buffer> <End>
silent! iunmap <buffer> <Up>
silent! iunmap <buffer> <Down>
silent! iunmap <buffer> <Home>
silent! iunmap <buffer> <End>
else
echo "Wrap ON"
setlocal wrap linebreak nolist
set virtualedit=
setlocal display+=lastline
noremap <buffer> <silent> <Up> gk
noremap <buffer> <silent> <Down> gj
noremap <buffer> <silent> <Home> g<Home>
noremap <buffer> <silent> <End> g<End>
inoremap <buffer> <silent> <Up> <C-o>gk
inoremap <buffer> <silent> <Down> <C-o>gj
inoremap <buffer> <silent> <Home> <C-o>g<Home>
inoremap <buffer> <silent> <End> <C-o>g<End>
noremap <buffer> <silent> k gk
noremap <buffer> <silent> j gj
noremap <buffer> <silent> 0 g0
noremap <buffer> <silent> $ g$
endif
endfunction
autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class
autocmd BufRead *.py set nocindent
autocmd BufWritePre *.py normal m`:%s/\s\+$//e ``
filetype plugin indent on
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment