-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
145 lines (103 loc) · 4.03 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
" ==============================================================================
" vimrc - github.com/lukeelmers/dotfiles
" ==============================================================================
" /* vim: set fdm=marker : */
set nocompatible
set encoding=utf8
" GENERAL ------------------------------------------------------------------{{{
set cursorline " Highlight underneath cursor
set backspace=indent,eol,start " Allow backspace in insert mode
set visualbell " No sounds
set autoread " Reload files changed outside vim
set showmatch " Show matching parenthesis
set undolevels=1000 " Store lots of undo
set history=1000 " Store lots of history
set noswapfile " Disable .swp file creation
set nobackup
set nowb
" Line numbers - use relative numbers unless we're in insert mode
set number " Line numbers
autocmd InsertEnter * silent! :set norelativenumber
autocmd InsertLeave,BufNewFile,VimEnter * silent! :set relativenumber
" Use tab key to match bracket or tag pairs
nnoremap <tab> %
vnoremap <tab> %
if v:version >= 600
runtime macros/matchit.vim
endif
" Map semicolon to colon in all modes, and hit semicolon twice if holding shift
map ; :
noremap ;; ;
" Map jj to ESC for quicker escaping
inoremap jj <ESC>
" Let buffers exist in the background without being in a window.
set hidden
" Allow the . to execute once for each line of a visual selection
vnoremap . :normal .<CR>
" Change leader to a space
let mapleader="\<Space>"
" }}}
" PLUGINS ------------------------------------------------------------------{{{
" This loads all the plugins specified in ~/.vim/plugins.vim
if filereadable(expand("~/.vim/plugins.vim"))
source ~/.vim/plugins.vim
endif
filetype plugin on
filetype indent on
" }}}
" TEXT & TABS --------------------------------------------------------------{{{
set wrap " Wrap lines
set linebreak " Wrap lines at convenient points
set nolist " List disables linebreak
set textwidth=79
if v:version > 740
set breakindent
endif
" Display tabs and trailing spaces visually
set list listchars=tab:\ \ ,trail:·
" }}}
" SCROLLING & FOLDING ------------------------------------------------------{{{
set scrolloff=8 "Start scrolling when we're 8 lines away from margins
set sidescrolloff=15
set sidescroll=1
set foldmethod=indent
set foldnestmax=10
set nofoldenable " no folding by default
set foldlevelstart=99 " don't fold everything the first time you hit za
" }}}
" SEARCH -------------------------------------------------------------------{{{
set incsearch " Find the next match as we type the search
set hlsearch " Highlight searches by default
set ignorecase " Ignore case when searching...
set smartcase " ...unless we type a capital
" Leader + Space to clear search highlight
nnoremap <leader><space> :noh<cr>
" }}}
" OTHER --------------------------------------------------------------------{{{
" Copy to and from system clipboard
set clipboard=unnamed,unnamedplus
" Recognize .md file as markdown
autocmd BufNewFile,BufReadPost *.md set filetype=markdown
" Open current document in default application (use to open html files in browser)
map <Leader>b :!open %<CR><CR>
" Quickly edit/reload the vimrc file
nmap <silent> <leader>ev :e $MYVIMRC<CR>
nmap <silent> <leader>sv :so $MYVIMRC<CR>
" Remove trailing whitespace
nnoremap <Leader>rtw :%s/\s\+$//e<CR>
" Additional settings for neovim
if has('nvim')
" Enter terminal emulator with <leader>t
nnoremap <leader>t :terminal<cr>
" Exit terminal emulator with <Esc> or <C-w><C-w>
tnoremap <Esc> <C-\><C-n>
tnoremap <C-w><C-w> <C-\><C-n><C-w><C-w>
endif
" Debug syntax highlighting: place cursor on any character and type :call SynStack()
fun! SynStack()
if !exists("*synstack")
return
endif
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")')
endfun
" }}}