-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.vim
More file actions
124 lines (105 loc) · 3.63 KB
/
config.vim
File metadata and controls
124 lines (105 loc) · 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
" Config ------------------------------
set nocompatible " use Vim settings, rather than Vi settings
set encoding=utf-8 " utf-8 encoding
set ruler " show cursor position in the statusbar
" set cursorline " show line under cursor
set number " show line numbers
set noshowmode " do not show the current mode of the editor
set showcmd " display incomplete commands
set autoread " auto-reload buffers when file changed on disk
set hidden " switch between buffers without saving them
" set visualbell " no sounds
set backspace=indent,eol,start " make backspace work as expected
if has('clipboard')
if has('unnamedplus')
set clipboard=unnamed,unnamedplus
else
set clipboard=unnamed
endif
endif
" set colorcolumn=80 " vertical ruler
" Backup & swap
set nobackup
set nowritebackup
set noswapfile
" Persistent undo
if has('persistent_undo')
set undofile
if has('nvim')
let s:undo_dir = stdpath('state') . '/undo'
elseif exists('*stdpath')
let s:undo_dir = stdpath('data') . '/undo'
else
let s:undo_dir = expand('~/.vim/undo')
endif
if !isdirectory(s:undo_dir)
call mkdir(s:undo_dir, 'p', 0700)
endif
let &undodir = s:undo_dir
endif
" Whitespace stuff
set expandtab " use spaces, not tabs
set autoindent " always set autoindenting on
set copyindent " copy the previous indentation on autoindenting
set nowrap " disable text wrapping
set tabstop=2
set shiftwidth=2
set softtabstop=2
" Tab completion
set wildmenu " better file/command completion
set wildmode=list:longest
set wildignore+=*.o,*.obj,*.png,*.jpg,*.gif,tags
set wildignore+=bundle/**,vendor/bundle/**,vendor/cache/**,vendor/gems/**
set wildignore+=log/**,tmp/**,*.scssc,*.sassc,*sass-cache*,coverage/**
" Splitting
set splitright " put new vertical windows right of the current one
set splitbelow " put new horizontal windows below of the current one
" Search
set hlsearch " highlight matches
" set incsearch " incremental search
set ignorecase " searches are case insensitive...
set smartcase " ... unless they contain at least one capital letter
set gdefault " /g flag on :s substitutions by default
" Look & Feel
if has('termguicolors')
set termguicolors
endif
set background=dark " dark background
set scrolloff=2 " min. number of screen lines above and below the cursor.
set laststatus=2 " show status line
syntax enable " enable syntax highlight
filetype plugin indent on "allow auto-indenting depending on file type
if exists('+pastetoggle')
set pastetoggle=<F2> " toggle paste mode
endif
set tags=.tags,tags
" Folding
" setl foldmethod=indent
function! TrimTrailingWhitespace()
if &buftype !=# ''
return
endif
if get(b:, 'trim_ws_disable', 0)
return
endif
let l:trim_ws_exclude = get(g:, 'trim_ws_exclude', ['markdown', 'diff'])
if index(l:trim_ws_exclude, &filetype) >= 0
return
endif
let l:view = winsaveview()
silent! %s/\s\+$//e
call winrestview(l:view)
endfunction
" Autodelete trailing whitespaces when saving
augroup config_trim_ws
autocmd!
autocmd BufWritePre * call TrimTrailingWhitespace()
augroup END
" When editing a file, always jump to the last known cursor position.
augroup config_last_cursor
autocmd!
autocmd BufReadPost *
\ if line("'\"") > 0 |
\ exe "normal! g`\"" |
\ endif
augroup END