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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
set nocompatible
set modelines=0 " for security
set encoding=utf-8
set mouse=""
set backspace=indent,eol,start
au FocusLost * :wa
" Leader ====----
nnoremap ,, ,
let mapleader=","
nnoremap <leader>; ;
nnoremap ; :
" Highlighting ====----
syntax on
filetype plugin indent on
set t_Co=256 " enable 256-color mode.
if &t_Co >= 256 || has("gui_running")
"colorscheme mustang
"colorscheme desert " set colorscheme
endif
if &t_Co > 2 || has("gui_running")
" switch syntax highlighting on, when the terminal has colors
syntax on
endif
" Indentation ====----
set shiftwidth=2
set tabstop=2
set expandtab
set shiftround " use multiple of shiftwidth with '<' and '>'
set autoindent
set copyindent " copy the previous line's indentation
" Search ====----
set incsearch
set hlsearch
set wrapscan
set ignorecase " ignore case when searching
set smartcase " ignore case if search pattern is all lowercase,
" case-sensitive otherwise
nnoremap <leader><space> :noh<cr>
" Case insensitive
nnoremap * /\<<C-R>=expand('<cword>')<CR>\><CR>
nnoremap # ?\<<C-R>=expand('<cword>')<CR>\><CR>
set showmatch
nnoremap <tab> %
vnoremap <tab> %
" Screen ====----
"set nowrap
set wrap
"set textwidth=79
"set formatoptions=tqrn1
set colorcolumn=85
set ruler
"set number " always show line numbers
set relativenumber
set laststatus=2
set cursorline
"set showmode
set showcmd
set title " change the terminal's title
set scrolloff=3
set visualbell " don't beep
set noerrorbells " don't beep
set list
set listchars=tab:>.,trail:.,extends:#,nbsp:.
"autocmd filetype html,xml set listchars-=tab:>.
set wildmenu
set wildmode=longest:full,full
set wildignore=*.swp,*.bak,*.pyc,*.class
set ttyfast
" Stop using arrow keys ====----
nnoremap <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
" nnoremap j gj
" nnoremap k gk
" Splits ====----
nnoremap <leader>w <C-w>v<C-w>l split
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
" History ====----
set history=1000 " remember more commands and search history
set undolevels=1000 " use many muchos levels of undo
if !isdirectory($HOME."/.vim")
call mkdir($HOME."/.vim", "", 0770)
endif
if !isdirectory($HOME."/.vim/undo-dir")
call mkdir($HOME."/.vim/undo-dir", "", 0700)
endif
set undodir=~/.vim/undo-dir
set undofile
" !!!! ADD THIS TO CRONTAB
" 43 0 * * 3 find /home/adam/.vim/undo-dir -type f -mtime +90 -delete
set nobackup
set noswapfile " Note: swap helps large files.
" Custom mappings ====----
" Quickly edit/reload the vimrc file
nnoremap <silent> <leader>ev :e $MYVIMRC<CR>
nnoremap <silent> <leader>sv :so $MYVIMRC<CR>
set pastetoggle=<F2>
nnoremap <leader>W :%s/\s\+$//<cr>:let @/=''<CR> " strip trailing whitespace
nnoremap <leader>ft Vatzf " fold tag
nnoremap <leader>S ?{<CR>jV/^\s*\}?$<CR>k:sort<CR>:noh<CR> " sort CSS
nnoremap <leader>q gqip " re-hardwrap
nnoremap <leader>v V`] " select pasted
vnoremap Q gq
nnoremap Q gqap
cnoremap w!! w !sudo tee % >/dev/null
|