-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
181 lines (142 loc) · 4.79 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
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
173
174
175
176
177
178
179
180
181
" .vimrc
" See: http://vimdoc.sourceforge.net/htmldoc/options.html for details
set nocompatible
" For multi-byte character support (CJK support, for example):
set fileencodings=utf-8,cp1251,latin1
set nowrap
set modeline
" Enable error files and error jumping.
set cf
" Show line numbers.
set number
" Highlight matching bracket.
set showmatch
" Search options.
set hlsearch
set ignorecase
set smartcase
" Display tabs and trailing spaces.
set list
if has("mouse")
" Enable the use of the mouse.
set mouse=a
endif
if exists("+undofile")
" Enable the persistent undo file(s)
set undodir=~/.vim/undo
set undofile
endif
set switchbuf+=usetab " Switch to existing tab; open a new tab for the new buf
let mapleader=","
filetype off
runtime bundle/vim-pathogen/autoload/pathogen.vim
execute pathogen#infect()
set background=dark
colorscheme mydark
" Configure plugins.
" supertab: tab-complete based on preceding characters (::, ->, . etc).
let g:SuperTabDefaultCompletionType = "context"
" vim-go: not just format the code; insert imports, too.
let g:go_fmt_command = "goimports"
" dart-vim-plugin: highlight HTML in strings, enforce syntax, format on save
let dart_html_in_string = v:true
let dart_style_guide = 2
let dart_format_on_save = 1
" Tell vim to remember certain things when we exit
" 'N : marks will be remembered for up to N previously edited files
" "N : will save up to N lines for each register
" :N : up to N lines of command-line history will be remembered
" % : saves and restores the buffer list
" n... : where to save the viminfo files
set viminfo='10,\"100,:100,n~/.viminfo
" Line width limit hint.
augroup EditorWidth
" colorcolumn breaks copy from terminal, so we use this instead.
au!
au BufEnter * highlight OverLength ctermbg=darkred
au BufEnter * match OverLength /\%81v./
au BufEnter *.go match OverLength /\%101v./
au BufEnter *.java match OverLength /\%101v./
au BufEnter *.data match OverLength /$$/
au BufEnter .vimrc match OverLength /$$/
augroup END
" Custom filetypes.
au BufNewFile,BufRead *.pi setf python
filetype indent off
" Automatically insert the current comment leader after hitting <Enter> in Insert mode.
set formatoptions=r
" Indentation settings.
" Width of the TAB column displayed on the screen, in spaces. A value of 8
" means that it will be consistent with console, printer and others.
set tabstop=8
" Number of spaces inserted when pressing TAB, or removed when pressing
" BACKSPACE. If 0, TAB inserts <tabstop> spaces, and automatically converts
" them to TAB characters per <tabstop> and <expandtab>.
set softtabstop=0
" shiftwidth: number of spaces inserted when using indentation methods,
" like >>, <<, ==. If shiftwidth=tabstop, a TAB character is inserted instead
" of spaces. When shifting, spaces will be replaced by TAB characters as
" necessary.
set shiftwidth=8
" smarttab: typing TAB in front of the line behaves like >>, while in text,
" typing TAB will add <softtabstop> spaces and convert spaces to TAB
" characters per <tabstop> and <expandtab>.
set smarttab
" When a new line is added, keep indentation level of the previous line.
set autoindent
" When a new line is added, copy exactly indentation level of the previous
" line (i.e. do not try to replace <tabstop> spaces with tabs).
set copyindent
set preserveindent
" expandtab: ALWAYS insert <shiftwidth> spaces when typing TAB.
set noexpandtab
" Shortcuts.
nnoremap ` :ShowMarksOnce<cr>`
noremap <C-\> :let @/ = ""<CR>
" Window navigation map.
fu! Amap(key, cmd, ...)
let l:cr="<CR>"
let l:p=":"
let l:key="<" . a:key . ">"
if a:0 > 0
if a:1 == 0
let l:cr=""
let l:p=""
endif
if a:1 > 0
let l:key=a:key
endif
endif
exe "nmap " . l:key . " " . l:p . a:cmd . l:cr
exe "vmap " . l:key . " <ESC>" . l:key . "<ESC>gv"
exe "imap " . l:key . " <c-o>" . l:key . ""
endf
call Amap("C-t", "tabnew")
call Amap("C-b", ":ls<CR>:b<Space>", 0)
call Amap("C-w", "close")
" Backspace navigates 'Back'
nmap <BS> <C-O>
nmap <S-BS> <C-I>
" Working with clipboard over SSH
" This doesn't paste; it prepares vim to do so. Use ^D when finished.
call Amap("zp", "r !cat", 1)
" This doesn't yank; it (un)prepares vim to do so.
call Amap("zy", "setl paste! number! list! <bar> NoShowMarks <bar> GitGutterToggle", 1)
" https://github.com/mobile-shell/mosh/issues/637 D'oh, really Mosh?!
" Well at least works with SecureShell + screen.
noremap <silent> <Leader>y :w !printf "
\$([[ "${TERM/-*/}" == screen ]] && printf "\eP")
\\e]52;c;$(base64 -w0)\a
\$([[ "${TERM/-*/}" == screen ]] && printf "\e\\")"<Return><Esc>
" Convenient write commands. w!! for sudo, others for holding Shift for too long.
cmap w!! %!sudo tee >/dev/null %<CR>
command WQ wq
command Wq wq
command W w
command Q q
command Qa qa
command QA qa
" Local machine overrides.
if filereadable(expand("~/.vimrc_local"))
source ~/.vimrc_local
endif