-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvimrc.basic
172 lines (129 loc) · 4.59 KB
/
vimrc.basic
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
" ~/.vimrc
" Use vim settings, rather than vi settings.
" This must be first, because it changes other options as a side effect.
set nocompatible
" Change the mapleader from \ to ,
let mapleader=","
set ruler
set scrolloff=4
set showtabline=2
set cmdheight=1
set showcmd
set showmode
set showmatch
set tabstop=4
set softtabstop=4
set expandtab
set shiftwidth=4
set shiftround
set smarttab
set autoindent
set copyindent
set gdefault
set hlsearch
set incsearch
set smartcase
set termencoding=utf-8
set encoding=utf-8
set lazyredraw
set ttyfast
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
" specifies what end-of-line formats will be tried when editing a new buffer
set fileformats="unix,dos,mac"
" don't show invisible characters by default, but it is enabled
" for some filetypes (see later)
set nolist
" strings to use in 'list' mode for the :list command
set listchars=tab:▸\ ,trail:·,extends:#,nbsp:·
" hide buffers instead of closing them. this means that the current buffer can
" be put to background without being written; and that marks and undo history
" are preserved
set hidden
" reveal already opened files from the quickfix window, instead of opening
" new buffers
set switchbuf=useopen
" remember more commands and search history
set history=1000
set undolevels=1000
" read/write a .viminfo file, don't store more than 80 lines of registers
set viminfo='20,\"80
" make tab completion for files/buffers act like bash
set wildmenu
" show a list when pressing tab, and complete first full match
set wildmode=list:full
" ignore completion for these files
set wildignore=*.swp,*.bak,*.pyc,*.class
" change the terminal's title
set title
" don't beep
set visualbell
set noerrorbells
" modeline settings
set modeline
set modelines=5
" when changing a line, don't redisplay, but put a '$' at the end during the change
set cpoptions+=$
" don't start new lines w/ comment leader on pressing 'o'
set formatoptions-=o
" somehow, during vim filetype detection, this gets set for vim files,
" so explicitly unset it again
au filetype vim set formatoptions-=o
" -----------------------------------------------------------------------------
" Horizontal rule separator (80 characters wide)
function! HorizontalRule()
let @s = "-------------------------------------------------------------------------------"
put s
endfunction
nnoremap <silent> <leader>hr :call HorizontalRule()<CR>
" -----------------------------------------------------------------------------
set foldenable " enable folding
"set foldcolumn=2 " add a fold column
set foldmethod=marker " detect triple-{ style fold markers
set foldlevelstart=0 " start out with everything folded
" which commands trigger auto-unfold
set foldopen=block,hor,insert,jump,mark,percent,quickfix,search,tag,undo
" customize the text displayed for a closed fold
set foldtext=MyFoldText()
function! MyFoldText()
let line = getline(v:foldstart)
let nucolwidth = &fdc + &number * &numberwidth
let windowwidth = winwidth(0) - nucolwidth - 3
let foldedlinecount = v:foldend - v:foldstart
" expand tabs into spaces
let onetab = strpart(' ', 0, &tabstop)
let line = substitute(line, '\t', onetab, 'g')
let line = strpart(line, 0, windowwidth - 2 -len(foldedlinecount))
let fillcharcount = windowwidth - len(line) - len(foldedlinecount) - 4
return line . ' …' . repeat(" ",fillcharcount) . foldedlinecount . ' '
endfunction
" -----------------------------------------------------------------------------
" switch syntax highlighting on, when the terminal has colors
if &t_Co > 2 || has("gui_running")
syntax on
endif
" restore cursor position upon reopening files
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
" enable the use of the mouse if terminal emulator supports it (xterm does)
set mouse=a
" when in normal mode, press <F12> to toggle mouse usage
nnoremap <F12> :call ToggleMouse()<CR>
function! ToggleMouse()
if &mouse == 'a'
set mouse=
echo "Mouse usage disabled"
else
set mouse=a
echo "Mouse usage enabled"
endif
endfunction
" when in insert mode, press <F2> to go to paste mode, where you can
" paste mass data that won't be autoindented
set pastetoggle=<F2>
" Set up vim to use the system clipboard
set clipboard=unnamed
" -----------------------------------------------------------------------------
" remap j and k to act as expected when used on long, wrapped lines
nnoremap j gj
nnoremap k gk
" -----------------------------------------------------------------------------