-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
109 lines (87 loc) · 2.51 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
set nocompatible
set modeline
syntax on
" Remove = from filename characters (when using gf)
set isfname-==
" Remap 'q' to quit vim
" Disables the macro recording
nnoremap q :q<CR>
" swp files are annoying. Let's hope vim doesn't crash
set nobackup
set nowritebackup
set noswapfile
" Use system clipboard for copy/paste
set clipboard=unnamedplus
" Enhance wildmenu for command-line completion
set wildmenu
set wildmode=longest:full,full
" searching
set showmatch
set incsearch
set hlsearch
" make searches case-sensitive only if they contain upper-case characters
set ignorecase smartcase
" indenting
filetype plugin indent on
set autoindent
" On pressing tab, insert 4 spaces
set expandtab
" show existing tab with 4 spaces width
set tabstop=4
set softtabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
"replace <TAB> with spaces
set expandtab
" backspace over autoindentation, line breaks and start of insert mode
set backspace=indent,eol,start
set pastetoggle=<F5>
function! <SID>StripTrailingWhitespaces()
let l = line(".")
let c = col(".")
%s/\s\+$//e
call cursor(l, c)
endfun
autocmd BufWritePre * :call <SID>StripTrailingWhitespaces()
function TrimEndLines()
let save_cursor = getpos(".")
:silent! %s#\($\n\s*\)\+\%$##
call setpos('.', save_cursor)
endfunction
au BufWritePre * call TrimEndLines()
if has("autocmd")
augroup Git
au!
au BufRead COMMIT_EDITMSG normal 1G
au BufRead COMMIT_EDITMSG set tw=72
augroup END
endif
" map <Home> to move to first word in line
" if at first word, move to beginning of line
nnoremap <silent> <Home> :call SmartHome("n")<CR>
inoremap <silent> <Home> <C-O>:call SmartHome("i")<CR>
vnoremap <silent> <Home> <Esc>:call SmartHome("v")<CR>
function! SmartHome(mode)
if strpart(getline('.'), -1, col('.')) =~ '^\s\+$'
normal! 0
else
normal! ^
endif
if a:mode == "v"
normal! msgv`s
endif
endfun
" vundle
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
" plugins
call vundle#end() " required
filetype plugin indent on " required
" jump to the last position when reopening a file
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\""|exe "normal! zz" | endif