-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.vimrc
More file actions
116 lines (92 loc) · 3.35 KB
/
.vimrc
File metadata and controls
116 lines (92 loc) · 3.35 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
set nocompatible
set encoding=utf-8 fileencoding=utf-8 termencoding=utf-8
set secure
set textwidth=0
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set smarttab
set backspace=indent,eol,start
set nolist
set listchars=tab:⇥\ ,trail:·,extends:>,precedes:<,nbsp:␣,eol:⏎
set autoindent
set nowrap
set cursorline
set ignorecase
set nobackup
set nowritebackup
set noswapfile
set wildignore=*.swp,*.bak,*.pyc,*.class
set number relativenumber
set ruler
set lazyredraw
set regexpengine=1
set history=1000
filetype plugin on
syntax on
" nnoremap <SPACE> <Nop>
let mapleader = "\<Space>"
"nnoremap <Leader>x :.!perl -pe "/- \[ \]/ ? s/- \[ \]/- \[X\]/ : s/- \[X\]/- \[ \]/"<CR>
" C-R (redo) pastes the content of a register without leaving insert mode
nnoremap <Leader>d i<C-R>=strftime("%Y-%m-%d")<CR>
" Make Vim show ALL white spaces as a character
" https://stackoverflow.com/a/1675752/1521064
nnoremap <Leader>l :set list!<CR>
" So that you can quit with `;q`
" An alternative was to add `command Q q` so that I could quit with `:Q`
nnoremap ; :
vnoremap ; :
" http://vim.wikia.com/wiki/Avoid_the_escape_key
" Also, stay where you are instead of going back 1 position
inoremap jj <ESC>l
" Center screen on next/previous selection.
nnoremap n nzz
nnoremap N Nzz
" Last and next jump should center too.
nnoremap <C-o> <C-o>zz
nnoremap <C-i> <C-i>zz
" Change cursor shape in different modes For iTerm2 on OS X
" http://vim.wikia.com/wiki/Change_cursor_shape_in_different_modes
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_SR = "\<Esc>]50;CursorShape=2\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
" Disable arrows. Don't use them!
noremap <Up> <nop>
noremap <Down> <nop>
noremap <Left> <nop>
noremap <Right> <nop>
" Allow saving of files as sudo when I forgot to start vim using sudo. Save
" from path modification attacks and expliticly discard standard output.
cmap w!! w !sudo /usr/bin/tee > /dev/null %
set splitbelow
set splitright
let g:netrw_altv = 1 " when navigating a folder,
" hitting <v> opens a window at right side (default is left side)
" Removes trailing spaces
function TrimWhiteSpace()
%s/\s*$//
''
endfunction
" FileType specific settings
" You can invoke equalprg (reindent) with gg=G
autocmd FileType go setlocal equalprg=gofmt
autocmd FileType java autocmd BufWritePre <buffer> %s/\s\+$//e
autocmd FileType javascript setlocal tabstop=2 softtabstop=2 shiftwidth=2
autocmd FileType make setlocal noexpandtab
autocmd FileType python setlocal equalprg=black\ --quiet\ -l\ 140\ -
autocmd FileType xml setlocal equalprg=xmllint4
autocmd FileType yaml setlocal tabstop=2 softtabstop=2 shiftwidth=2 expandtab
if has('clipboard')
if has('unnamedplus')
" When possible use + register for copy-paste
set clipboard=unnamed,unnamedplus
else
" On mac and Windows, use * register for copy-paste
set clipboard=unnamed
endif
endif
" My macros. Convert a macro to text with `"ap` for a macro registered on `a`. Insert `<ESC>` in insert mode with `<C-v><Esc>`.
let @4 = '0g_1000a d40|j' " Insert spaces in current line up to column 40; move to the line below so that you can execute this on a block of text
let @8 = '0g_1000a d80|j' " Insert spaces in current line up to column 80; move to the line below so that you can execute this on a block of text
let @i = 'a<i></i>3hi' " Insert HTML tags for italic