-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.vim.remote
More file actions
189 lines (144 loc) · 4.23 KB
/
init.vim.remote
File metadata and controls
189 lines (144 loc) · 4.23 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
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
182
183
184
185
186
187
188
189
"" basics
set nocompatible
syntax enable
filetype plugin indent on
let mapleader = ","
set number
set encoding=utf-8
" disable swap files
set noswapfile
set hidden
" menu for choosing files
set wildmode=list:longest,full
set wildmenu
set wildignore=*.o,*.obj,*.aux,*.nav,*.out,*.snm,*.toc
" highlight the line with the cursor
set cursorline
" context around the cursor
set scrolloff=5
" write changes to file on certain occasions
set autowrite
set backspace=indent,eol,start
" make sure there is no sound when an error takes place
set noerrorbells
"set visualbell
" jump briefly to matching brackets
set noshowmatch " turned off: it is distracting with the current colorscheme
set matchtime=3
" formating
set textwidth=79
set colorcolumn=80
set listchars=eol:$,tab:>-,trail:~,extends:>,precedes:<
" Sets spaces used for (auto)indent
set tabstop=4
set shiftwidth=4
set softtabstop=4
" Tab key inserts spaces instead of tabs
set expandtab
set smarttab
" Indent to nearest tabstop
set shiftround
" indent
set cindent
set autoindent
" spell check
set spelllang=en_us
nmap <silent> <leader>s :set spell! <CR>
" security: prevent modeline exploits
set modelines=0
"" search
set incsearch
set hlsearch
set ignorecase
set smartcase
"" replace
set gdefault " :%s/foo/bar should replace in whole file not just current line
"" folding
set foldmethod=indent
set foldlevelstart=10
"" color scheme
colorscheme darkblue
set t_Co=256
set t_ut=
let g:rehash256=1
set background=dark
" :W should save as well
command Wq wq
command WQ wq
command Q q
" save files when runing vim with wrong permissions
command W :execute ':silent w !sudo tee % > /dev/null' | :edit!
" ========================================================================
" Function Keys - F*
" ========================================================================
" disable F1 help
nmap <F1> :echo<CR>
imap <F1> <C-o>:echo<CR>
"" Hexedit
nnoremap <F4> :Hexmode<CR>
inoremap <F4> <Esc>:Hexmode<CR>
vnoremap <F4> :<C-U>Hexmode<CR>
" ex command for toggling hex mode - define mapping if desired
command -bar Hexmode call ToggleHex()
" helper function to toggle hex mode
function ToggleHex()
" hex mode should be considered a read-only operation
" save values for modified and read-only for restoration later,
" and clear the read-only flag for now
let l:modified=&mod
let l:oldreadonly=&readonly
let &readonly=0
let l:oldmodifiable=&modifiable
let &modifiable=1
if !exists("b:editHex") || !b:editHex
" save old options
let b:oldft=&ft
let b:oldbin=&bin
" set new options
setlocal binary " make sure it overrides any textwidth, etc.
let &ft="xxd"
" set status
let b:editHex=1
" switch to hex editor
%!xxd
else
" restore old options
let &ft=b:oldft
if !b:oldbin
setlocal nobinary
endif
" set status
let b:editHex=0
" return to normal editing
%!xxd -r
endif
" restore values for modified and read only state
let &mod=l:modified
let &readonly=l:oldreadonly
let &modifiable=l:oldmodifiable
endfunction
" ========================================================================
" File type matching
" ========================================================================
if has("autocmd")
" changes working directory to the directory of the last opened file
au BufEnter * if expand("%:p:h") !~ '^/tmp' | lcd %:p:h | endif
"autocmd BufEnter * :lcd %:p:h
" go to the line where the last edit took place
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$") | exe "normal g'\""| endif
" Turn off line wrap for common files
au BufNewFile,BufRead db.* setlocal nowrap nofen
au BufNewFile,BufRead /etc/* setlocal nowrap nofen
"" C
au FileType c setl sw=8 ts=8 sts=8 noexpandtab cindent "list
"" Ruby
au FileType ruby setl sw=2 sts=2 expandtab "list
endif
" ========================================================================
" Macros
" ========================================================================
"" trim trailing whitespaces
nnoremap <silent> <Leader>rts :call TrimWhiteSpace()<CR>
function! TrimWhiteSpace()
%s/\s\+$//e
endfunction