2012-01-06 10:56:50 +01:00
|
|
|
" I probably don't need to have Vi compatibility.
|
|
|
|
set nocompatible
|
|
|
|
|
2012-12-21 12:08:42 +01:00
|
|
|
" Show syntax colours
|
2011-12-31 20:40:19 +01:00
|
|
|
syntax on
|
|
|
|
|
2018-12-17 10:50:47 +01:00
|
|
|
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)
|
2011-12-31 20:40:19 +01:00
|
|
|
|
|
|
|
" Source a global configuration file if available
|
|
|
|
if filereadable("/etc/vim/vimrc.local")
|
2018-12-17 10:50:47 +01:00
|
|
|
source /etc/vim/vimrc.local
|
2011-12-31 20:40:19 +01:00
|
|
|
endif
|
|
|
|
|
2018-12-17 10:50:47 +01:00
|
|
|
set number " Show line numbers.
|
2011-12-31 20:40:19 +01:00
|
|
|
|
2018-12-17 10:50:47 +01:00
|
|
|
set ruler " Show the line and column number of the cursor position,
|
|
|
|
" separated by a comma.
|
2012-01-01 11:11:15 +01:00
|
|
|
|
2018-10-11 12:11:06 +02:00
|
|
|
set background=dark
|
2012-12-21 12:08:42 +01:00
|
|
|
|
2012-01-01 11:11:15 +01:00
|
|
|
"Use modelines!
|
|
|
|
set modeline
|
2020-04-17 14:09:08 +02:00
|
|
|
|
|
|
|
" These may be difficult with multiple languages especially if Vim already
|
|
|
|
" knows what to do
|
|
|
|
"set tabstop=4 "four spaces is likely a tab
|
2018-10-11 12:11:06 +02:00
|
|
|
"set shiftwidth=4
|
2020-04-17 14:09:08 +02:00
|
|
|
"set expandtab
|
|
|
|
|
2012-01-01 11:11:15 +01:00
|
|
|
set autoindent
|
|
|
|
|
2012-01-06 10:56:50 +01:00
|
|
|
" Longer history
|
|
|
|
set history=1000
|
|
|
|
|
|
|
|
" Extended % matching
|
|
|
|
runtime macros/matchit.vim
|
|
|
|
|
|
|
|
" Make tab filler useful.
|
2018-10-11 12:11:06 +02:00
|
|
|
" INVESTIGATE WHAT THIS ACTUALLY DOES?
|
2012-01-06 10:56:50 +01:00
|
|
|
set wildmenu
|
|
|
|
set wildmode=list:longest
|
|
|
|
|
|
|
|
" Flash, do not beep!
|
|
|
|
set visualbell
|
2012-03-23 17:13:17 +01:00
|
|
|
|
|
|
|
" gvim has light background
|
|
|
|
if has('gui_running')
|
2018-12-17 10:50:47 +01:00
|
|
|
set background=light
|
2012-03-23 17:13:17 +01:00
|
|
|
endif
|
2014-05-14 13:38:29 +02:00
|
|
|
|
2018-10-11 12:11:06 +02:00
|
|
|
" Show hidden characters via
|
2020-01-02 15:08:42 +01:00
|
|
|
" https://www.perturb.org/display/679_Make_Vim_show_hidden_characters.html
|
2014-05-14 13:38:29 +02:00
|
|
|
set invlist
|
|
|
|
|
|
|
|
"Prefer to UNIX line endings, but understand DOS too.
|
|
|
|
set fileformats=unix,dos
|
|
|
|
|
|
|
|
"Use UTF-8!
|
|
|
|
set encoding=utf-8
|
|
|
|
set fileencoding=utf-8
|
|
|
|
|
2018-10-11 12:11:06 +02:00
|
|
|
" Remove BOMs. They broke things yesterday and now they wasted my time
|
|
|
|
" at school!
|
2020-01-02 15:08:42 +01:00
|
|
|
" via https://techwelkin.com/how-to-remove-byte-order-mark-bom-characters
|
2014-05-14 13:38:29 +02:00
|
|
|
set nobomb
|
2014-05-14 13:52:49 +02:00
|
|
|
|
2020-04-17 14:09:08 +02:00
|
|
|
" Apply rules per filetype.vim
|
|
|
|
set filetype
|
2014-05-14 13:52:49 +02:00
|
|
|
filetype plugin indent on
|
|
|
|
|
|
|
|
" Return to last edit position when opening files (You want this!)
|
|
|
|
autocmd BufReadPost *
|
2018-12-17 10:50:47 +01:00
|
|
|
\ if line("'\"") > 0 && line("'\"") <= line("$") |
|
|
|
|
\ exe "normal! g`\"" |
|
|
|
|
\ endif
|
2014-06-08 10:56:38 +02:00
|
|
|
|
2020-01-02 15:08:42 +01:00
|
|
|
" dos2unix ^M copied from https://stackoverflow.com/a/5361702/1675649
|
2014-06-08 10:56:38 +02:00
|
|
|
fun! Dos2unixFunction()
|
2018-12-17 10:50:47 +01:00
|
|
|
let _s=@/
|
|
|
|
let l = line(".")
|
|
|
|
let c = col(".")
|
|
|
|
try
|
|
|
|
set ff=unix
|
|
|
|
w!
|
|
|
|
"%s/\%x0d$//e
|
|
|
|
catch /E32:/
|
|
|
|
echo "Sorry, the file is not saved."
|
|
|
|
endtry
|
|
|
|
let @/=_s
|
|
|
|
call cursor(l, c)
|
2014-06-08 10:56:38 +02:00
|
|
|
endfun
|
|
|
|
com! Dos2Unix keepjumps call Dos2unixFunction()
|
|
|
|
au BufReadPost * keepjumps call Dos2unixFunction()
|
2014-06-13 21:01:19 +02:00
|
|
|
|
2014-08-28 13:15:25 +02:00
|
|
|
" Highlight all search results
|
|
|
|
set hlsearch
|
2019-02-08 13:22:36 +01:00
|
|
|
|
|
|
|
" Red column on the right as indication on what I wish to consider as the
|
|
|
|
" maximum length of a line.
|
|
|
|
set colorcolumn=76
|