forked from l0b0/tilde
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
110 lines (82 loc) · 2.52 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
" 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
" Enable mouse usage (all modes) in terminals
"set mouse=a
" 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 ruby,eruby,yaml
\ set autoindent shiftwidth=2 softtabstop=2 expandtab
autocmd FileType c set autoindent shiftwidth=4 softtabstop=4 noexpandtab
" 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
runtime plugin/adjust-tabstop.vim
" Highlight starting with 80th column as oversize warning
highlight OverLength ctermfg=red guibg=#592929
match OverLength /\%80v.\+/
" Map Ctrl-J to insert linefeed after and Ctrl-K - before.
" Leaves cursor in position through ` mark
nnoremap <C-k> m`O<Esc>``
nnoremap <C-j> m`o<Esc>``
" Map Ctrl-L to split the line at current position
nnoremap <C-L> m`i<CR><Esc>``
" nnoremap <C-L> m`ciW<CR><Esc>:if match( @", "^\\s*$") < 0<Bar>
" \ exec "norm P-$diw+"<Bar>endif<CR>``