-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
123 lines (103 loc) · 3.63 KB
/
.vimrc
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
" Enable syntax highlighting,
syntax on
" Enable file type plug,
filetype plugin on
filetype indent on
" Fast saving,
map qq :w!<cr>
" Toggle long lines highlighting,
map åå :call ShowLongLines()<cr>
" Toggle spell checking,
map ää :setlocal spell!<cr>
" Never do sudo vim again,
cmap w!! w !sudo tee %
" Not really sure,
scriptencoding utf-8
" Set some reasonable defaults
set autoindent " Simple indent
set cmdheight=2 " Height of the command bar
set cursorline " highlight current line
set encoding=utf-8 " Show files in utf8
set expandtab " Inserts <softtabstop-nr-of-spaces> instead of tabs
set fileencoding=utf-8 " Save files in utf8
set guifont=Monospace\ 9 " Font in gui
set hls " Highlight matches
set hlsearch " Highlight search results
set ic " Ignore case while searching
set incsearch " Search while typing
set laststatus=2 " Always show the status line
set lazyredraw " Don't redraw while executing macros (good performance)
set linebreak " Line break
set magic " For regular expressions turn magic on
set mat=2 " How many 10ths of a second to blink when matching brackets
set number " Always show number-row
" set paste " Always paste mode
set ruler " Always show current position
set shiftwidth=2 " Number of spaces to use when indenting
set showmatch " Show matching brackets when text indicator is over them
set smartcase " When searching try to be smart about cases
set showcmd " show command in bottom bar
set softtabstop=2 " Magic derp
set tabpagemax=50 " Maximum number of tabs allowed open
set tabstop=2 " The amount of spaces a tab should be
set viminfo^=% " Remember info about open buffers on close
set wrap " Line break
set wildmenu " visual auto complete for command menu
set backup
set writebackup
set backupdir^=$HOME/.cache//
set directory^=$HOME/.cache//
set undodir^=$HOME/.cache//
" Highlight pattern dangling spaces,
:highlight ExtraWhitespace ctermbg=darkgreen guibg=lightgreen
:match ExtraWhitespace /\s\+$\| \+\ze\t/
" Return to last edit position when opening files,
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
" Some magic,
augroup configgroup
autocmd!
autocmd BufWritePre * :call StripTrailingWhitespaces()
autocmd BufEnter Makefile setlocal noexpandtab
augroup END
" Playing with themes,
colorscheme badwolf
" Make the gutters darker than the background.
let g:badwolf_darkgutter = 1
" Make the tab line much lighter than the background.
let g:badwolf_tabline = 3
" Turn on CSS properties highlighting
let g:badwolf_css_props_highlight = 1
" Tabs
highlight SpecialKey ctermfg=red
set list
set listchars=tab:..,trail:_,extends:>,precedes:<,nbsp:~
"
" Functions
"
" Toggle red indicator at 80 chars
let s:color_column_toggle = 0
highlight ColorColumn ctermfg=red ctermbg=233
function! ShowLongLines()
if s:color_column_toggle == 0
let w:m1 = matchadd('ColorColumn', '\%81v')
let s:color_column_toggle = 1
else
call matchdelete(w:m1)
let s:color_column_toggle = 0
endif
endfunction
" Removes dangling spaces, called on buffer write in the autogroup above.
function! StripTrailingWhitespaces()
" save last search & cursor position
let _s=@/
let l = line(".")
let c = col(".")
%s/\s\+$//e
let @/=_s
call cursor(l, c)
endfunction
" Call these at startup,
call ShowLongLines()