-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvimrc
More file actions
83 lines (68 loc) · 1.75 KB
/
vimrc
File metadata and controls
83 lines (68 loc) · 1.75 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
" Activate pathogen
filetype off
call pathogen#infect()
" Shortcut to rapidly toggle 'set list'
nmap <leader>l :set list!<CR>
" User the same symbols as TextMate for tabstops and EOLs
set listchars=tab:▸\ ,eol:¬
" Set indentation preferences
set ts=4 sts=4 sw=4 expandtab
set autoindent
set smartindent
" Wrapping
"set textwidth=79
"set wrap
" Code folding
set foldmethod=indent
set foldlevel=99
" Make moving around wrapped lines easier
vmap <D-j> gj
vmap <D-k> gk
vmap <D-4> g$
vmap <D-6> g^
vmap <D-0> g^
nmap <D-j> gj
nmap <D-k> gk
nmap <D-4> g$
nmap <D-6> g^
nmap <D-0> g^
" Settings for vim compiled with autocmd enabled
if has("autocmd")
" Enable file type detection
filetype on
" Syntax of these languages is fussy over tabs vs spaces
autocmd FileType make setlocal ts=4 sts=4 sw=4 noexpandtab
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 expandtab
" Smartindent not good for python
autocmd FileType python setlocal nosmartindent
" Clean trailing whitespace on buffer write
autocmd BufWritePre *.py,*.js,*.c,*.h,*.cpp :call Preserve("%s/\\s\\+$//e")
" Source the vimrc file after saving it
autocmd BufWritePost .vimrc,vimrc source $MYVIMRC
endif
function! Preserve(command)
" Save history
let _s=@/
" Save cursor position
let l = line(".")
let c = col(".")
" Execute command
execute a:command
" Restore history and cursor
let @/=_s
call cursor(l,c)
endfunction
" Use _$ as a shortcut to remove trailing whitespace in a file
nmap _$ :call Preserve("%s/\\s\\+$//e")<CR>
" Make shifting between windows easier
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
filetype plugin indent on
syntax on
set ruler
set number
set showmatch
set t_Co=256
colorscheme molokai