This repository has been archived by the owner on Jun 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
.vimrc
91 lines (67 loc) · 1.97 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
" Not running Vi
set nocompatible
" Syntax highlighting
syntax on
" Command history
set history=1000
" If using a dark background within the editing area and syntax highlighting
set background=dark
" Jump to the last position when reopening a file
if has("autocmd")
au BufReadPost * if line("'\"") > 0 && line("'\"") <= line("$")
\| exe "normal g'\"" | endif
endif
" Load indentation rules according to the detected filetype
filetype plugin indent on
" Show (partial) command in status line
set showcmd
" Show matching brackets.
set showmatch
" Do case insensitive matching
set ignorecase
" Do smart case matching
set smartcase
" Incremental search
set incsearch
" Automatically save before commands like :next and :make
set autowrite
" Hide buffers when they are abandoned
set hidden
" Backspace behaving as in other editors
set backspace=indent,eol,start
" Press F2 before pasting text to avoid crazy indentation
set pastetoggle=<F2>
" Indentation/tabs
set tabstop=4
set shiftwidth=4
set expandtab
autocmd FileType c set autoindent shiftwidth=4 softtabstop=4 noexpandtab
autocmd FileType eruby,ruby,yaml set autoindent shiftwidth=2 softtabstop=2 expandtab
" Switch between tabs and spaces for indentation
nmap <silent> <S-t> :set expandtab! | if &expandtab | retab | echo 'spaces' | else | retab! | echo 'tabs' | endif<CR>
" Highlight trailing whitespace characters
match Todo /\s\+$/
" Replace CR with LF
noremap <C-n> :%s/\r/\r/g <CR>
" Reformat current paragraph
noremap <C-f> gwap
" Sort words
command! -nargs=0 -range SortWords call VisualSortWords()
function! VisualSortWords()
let rv = @"
let rt = getregtype('"')
try
norm! gvy
call setreg('"', join(sort(split(@")), ' '), visualmode()[0])
norm! `>pgvd
finally
call setreg('"', rv, rt)
endtry
endfunction
" Unicode
set encoding=utf-8
" Temporary files
set backupdir=~/.vimtmp,.
set directory=~/.vimtmp,.
" Load plugins
autocmd BufEnter * runtime plugin/adjust-tabstop.vim