-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathvimrc
More file actions
95 lines (82 loc) · 3 KB
/
vimrc
File metadata and controls
95 lines (82 loc) · 3 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
" Some of the good parts (TM) from `$VIMRUNTIME/defaults.vim` are included here.
set mouse=a " Enable use of the mouse in all modes.
set history=10000 " This is the maximum (and Neovim's default).
set incsearch " Search while typing the search command and...
set hlsearch " ...hightlight matches.
set viminfofile=~/.viminfo10k
set shortmess-=S
set shortmess+=F
let &t_SI = "\e[6 q"
let &t_EI = "\e[2 q"
" This prevents XTerm's `modifyOtherKeys` feature being enabled automatically. See `:h
" modifyOtherKeys`. The `modifyOtherKeys` feature facilitates Vim recognizing and
" distinguishing more key combinations, but stuff like Alt+b and Alt+f in Vim's built-in
" terminal breaks when the feature is enabled. I added this on 2025-05-17.
let &t_TI = ""
let &t_TE = ""
set maxmem=2000000 " Lots of memory for each buffer.
set maxmemtot=2000000 " Lots of memory for all buffers together.
if has('unix')
source ~/.vim/common.vim
elseif has('win32')
source ~/vimfiles/common.vim
endif
" TODO: explain.
if has('unix')
let s:vimfiles = $HOME .. '/.vim'
elseif has('win32')
" Use $HOME or $USERPROFILE?
let s:vimfiles = $HOME .. '/vimfiles'
endif
if exists('s:vimfiles')
if !isdirectory(s:vimfiles .. '/swp')
call mkdir(s:vimfiles .. '/swp', 'p')
endif
if !isdirectory(s:vimfiles .. '/undo')
call mkdir(s:vimfiles .. '/undo', 'p')
endif
if !isdirectory(s:vimfiles .. '/backup')
call mkdir(s:vimfiles .. '/backup', 'p')
endif
let &dir = s:vimfiles .. '/swp//'
let &undodir = s:vimfiles .. '/undo'
let &backupdir = s:vimfiles .. '/backup'
endif
" https://stackoverflow.com/questions/1549263/how-can-i-create-a-folder-if-it-doesnt-exist
" https://vim.wikia.com/wiki/Automatically_create_tmp_or_backup_directories
" If running inside screen, use these escape sequences to name the window (set the title
" of the VT100 emulated by screen).
if &term =~# 'screen'
set t_ts=k
set t_fs=\
endif " The settings for those termcap codes are taken from
" https://vim.wikia.com/wiki/Automatically_set_screen_title.
if exists('&belloff')
set belloff=all
endif
" Fallback method to disable beeping in case the 'belloff' option doesn't exist or doesn't
" work. See :h 'vb' and :h exists().
if !exists('+belloff')
set visualbell
set t_vb=
endif
" I copied this from sensible.vim [1]. Neovim doesn't need it [2].
if has('autocmd')
filetype plugin indent on
endif
if has('syntax') && !exists('g:syntax_on')
syntax enable
endif
" [1]: https://github.com/tpope/vim-sensible/blob/master/plugin/sensible.vim
" [2]: https://github.com/neovim/neovim/issues/2676
" This makes stuff like `inoremap <A-h> <Left>` work. But it breaks the default Readline
" behavior in Vim's built-in terminal, which is why we're skipping a few letters. In
" Neovim, everything works out of the box.
for i in range(97, 122) + range(48, 57)
let c = nr2char(i)
if c == "a" || c == "b" || c == "d" || c == "f"
continue
endif
exe "set <A-" .. c .. ">=\e" .. c
endfor
exe "set <A-CR>=\e\r"