about summary refs log tree commit diff
path: root/vim/.vim/vimrc
blob: a7f628bcfbc0d4d02aee3228a4cee7df0018e0ef (plain) (blame)
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
set nocompatible

let g:skip_defaults_vim = 1

let $VIMFILES = expand('<sfile>:p:h')

set autoread
set backspace=indent,eol,start
set clipboard=unnamed,unnamedplus
set display+=lastline
set fillchars=vert:\ "
set hidden
set history=1000
set laststatus=2
set lazyredraw
set modeline
set mouse=
set noshowmode
set path+=**
set ruler
set tabpagemax=50
set viminfo=

set sessionoptions-=options
set viewoptions-=options

set noerrorbells
set novisualbell

set splitbelow
set splitright

set complete=
set complete+=.
set complete+=b
set complete+=t
set completeopt=
set completeopt+=menu
set completeopt+=longest

set gdefault
set hlsearch
set incsearch
set iskeyword+=-
set magic

set foldmethod=marker
set nofoldenable

set shortmess=
set shortmess+=I
set shortmess+=T
set shortmess+=a
set shortmess+=c
set shortmess+=t

set nolist
set nowrap

set scrolloff=10
set sidescrolloff=10

set number
if v:version >= 700
    set numberwidth=3
endif

set wildignorecase
set wildmenu
set wildignore=

set nobackup
set noswapfile
set noundofile
set nowritebackup

set smartcase
set ignorecase

set autoindent
set breakindent
set smartindent

set expandtab
set shiftround
set shiftwidth=4
set smarttab
set softtabstop=4
set tabstop=4

if &t_Co == 8 && $TERM !~# '^Eterm'
    set t_Co=16
endif

if &listchars ==# 'eol:$'
    set listchars=tab:>\ ,trail:-,extends:>,precedes:<,nbsp:+
endif

if v:version > 703 || v:version == 703 && has("patch541")
    set formatoptions+=j
endif

if has('path_extra')
    setglobal tags-=./tags tags-=./tags; tags^=./tags;
endif

if !has('nvim') && &ttimeoutlen == -1
    set ttimeout
    set ttimeoutlen=100
endif

try
    set encoding=utf-8
    scriptencoding utf-8
catch
endtry

try
    if &fileencodings !~? "utf-8"
        let g:added_fenc_utf8 = 1
        set fileencodings+=utf-8
    endif
catch
endtry

if has('autocmd')
    filetype plugin indent on

    if exists("+omnifunc")
        autocmd Filetype *
                    \ if &omnifunc == "" |
                    \ setlocal omnifunc=syntaxcomplete#Complete |
                    \ endif
    endif

    autocmd BufEnter * set noreadonly
endif

if has('syntax') && !exists('g:syntax_on')
    syntax enable
endif

if !exists('g:loaded_matchit') && findfile('plugin/matchit.vim', &rtp) ==# ''
    runtime! macros/matchit.vim
endif

let mapleader = ' '

nnoremap <Expr> j           v:count ? 'j' : 'gj'
nnoremap <Expr> k           v:count ? 'k' : 'gk'

nnoremap        J           gt
nnoremap        K           gT

nnoremap        <C-a>       ^h
vnoremap        <C-a>       ^h
nnoremap        H           ^h
vnoremap        H           ^h

nnoremap        <C-e>       $
vnoremap        <C-e>       $
nnoremap        L           $
vnoremap        L           $

nnoremap        N           Nzzzv
nnoremap        n           nzzzv

inoremap        <C-u>       <C-g>u<C-u>
inoremap        <C-w>       <C-g>u<C-w>

vnoremap        <           <gv
vnoremap        >           >gv
vnoremap        <Tab>       >gv
vnoremap        <S-Tab>     <gv
nnoremap        <Tab>       >>_
nnoremap        <S-Tab>     <<_

nnoremap        ]b          :<C-u>bnext<CR>
nnoremap        [b          :<C-u>bprevious<CR>

nnoremap        <C-h>       <C-w>h
nnoremap        <C-j>       <C-w>j
nnoremap        <C-k>       <C-w>k
nnoremap        <C-l>       <C-w>l

nnoremap        *           /\<<C-r>=expand('<cword>')<CR>\><CR>
nnoremap        #           ?\<<C-r>=expand('<cword>')<CR>\><CR>

nnoremap        <C-L>       :<C-u>nohlsearch<C-r>=has('diff')?'<Bar>diffupdate':''<CR><CR><C-l>

cnoremap        ;/          <C-r>=expand('%:p:h').'/'<CR>
cnoremap        ;;          <C-r>=expand('%:t')<CR>
cnoremap        ;.          <C-r>=expand('%:p:r')<CR>

nnoremap        <Leader>.   :<C-u>lcd %:p:h<CR>

nnoremap        Q           @q

nnoremap        <Leader>c   ^v$h
nnoremap        <Leader>v   ggVG

nnoremap        <Leader>y   "+y
nnoremap        <Leader>Y   "+Y

nnoremap        <Leader>p   "+p
nnoremap        <Leader>P   "+P

inoremap        <C-v>       <C-c>"+pi
cnoremap        <C-v>       <C-r>+

nmap            <Leader>w   :<C-u>w!<CR>
nmap            <Leader>wq  :<C-u>wq!<CR>

nnoremap        ZX          :<C-u>qa!<CR>

nnoremap        <Leader>q   :<C-u>q<CR>

command         W           w !sudo tee "%" >/dev/null

function! SwitchCase()
    normal! ~
    if strlen(getline('.')) != virtcol('.')
        normal! h
    endif
endfunction
nnoremap        ~           :<C-u>call SwitchCase()<CR>

function! s:GM()
    execute 'normal! ^'
    let first_col = virtcol('.')
    execute 'normal! g_'
    let last_col  = virtcol('.')
    execute 'normal! ' . (first_col + last_col) / 2 . '|'
endfunction
nnoremap        gm          :<C-u>call <SID>GM()<CR>
onoremap        gm          :<C-u>call <SID>GM()<CR>

Consider giving Nix/NixOS a try! <3