-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
72 lines (63 loc) · 2.01 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
" Load other config files
"" The bundle must be first loaded
runtime! config/bundle/*.vim
runtime! config/*.vim
runtime! config/*/*.vim
" Set configs
scriptencoding utf-8
set encoding=utf-8
set number
set ruler
set title
set expandtab
set tabstop=2
set shiftwidth=2
set smartindent
set list
set listchars=tab:»-,trail:*,eol:$,extends:»,precedes:«,nbsp:%
set virtualedit=block
set ignorecase
set hlsearch
set virtualedit=onemore
set cursorline
set laststatus=2
"" https://github.com/vim/vim/issues/2506
"" https://vim-jp.org/vimdoc-ja/options.html
set backupcopy=yes
set notitle
" Syntax highlight on
if has("syntax")
syntax on
endif
" Syntax highlight color
hi LineNr ctermfg=cyan
hi Comment ctermfg=lightgrey
hi NonText ctermfg=darkgrey
hi SpecialKey ctermfg=lightgrey
hi CursorLine ctermbg=17
"" Not work. Need to change the terminal preferences
"" Cursor color in preferences: R: 53, G: 125, B: 79
"" hi Cursor ctermbg=15 ctermfg=8
" Command alias
:command Soft set expandtab
:command Hard set noexpandtab
" Config for each filetype
autocmd BufNewFile,BufRead *.conf set tabstop=4 shiftwidth=4
autocmd BufNewFile,BufRead dir_colors set filetype=dircolors
autocmd BufNewFile,BufRead ~/.ssh/conf.d/*.conf set filetype=sshconfig
function! s:remove_dust()
let cursor = getpos(".")
%s/\s\+$//ge
call setpos(".", cursor)
unlet cursor
endfunction
" https://stackoverflow.com/a/67463224/13999144
autocmd BufWritePre *\(.diff\)\@<! call <SID>remove_dust()
" Always start on first line of git commit message
" cf. https://vim.fandom.com/wiki/Always_start_on_first_line_of_git_commit_message
autocmd FileType gitcommit call setpos('.', [0, 1, 1, 0])
" Set the filetype based on the file's extension, but only if
" 'filetype' has not already been set
" https://stackoverflow.com/questions/11666170/persistent-set-syntax-for-a-given-filetype#answer-28117335
"" https://unix.stackexchange.com/questions/68972/no-syntax-highlighting-when-editing-crontab#answer-71320
au BufRead,BufNewFile *.cron set filetype=crontab