-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
96 lines (92 loc) · 1.92 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
" ===
" === Settings
" ===
set number
set relativenumber
set shortmess+=I
set ignorecase
set smartcase
set nowrap
" set noswapfile
set incsearch
set smartindent
set splitright
set splitbelow
if has('nvim') || v:version >= 800
set termguicolors
endif
set guicursor=
" set cursorline
if has('nvim')
set exrc
endif
let os_name = system('uname -s')
if os_name !=# "Darwin\n"
language en_US.UTF-8
endif
set scrolloff=1
" === Filetype settings.
set tabstop=4
set shiftwidth=4
set expandtab
autocmd BufWritePre * set ff=unix
autocmd FileType json,markdown,html,css,lua,yaml setlocal tabstop=2 shiftwidth=2
" ===
" === Keymaps
" ===
inoremap <C-c> <C-[>
if has('nvim') || v:version >= 800
tnoremap <A-[> <C-\><C-n>
endif
" Change <C-a> and <C-x> to <A-a> and <A-x> in normal and visual mode.
nnoremap <C-a> <Nop>
nnoremap <A-a> <C-a>
vnoremap <C-a> <Nop>
vnoremap <A-a> <C-a>
nnoremap <C-x> <Nop>
nnoremap <A-x> <C-x>
vnoremap <C-x> <Nop>
vnoremap <A-x> <C-x>
" Disable s key.
nnoremap s <Nop>
vnoremap s <Nop>
nnoremap S <Nop>
vnoremap S <Nop>
" === Emacs cmdline
" start of line
:cnoremap <C-A> <Home>
" back one character
:cnoremap <C-B> <Left>
" delete character under cursor
:cnoremap <C-D> <Del>
" end of line
:cnoremap <C-E> <End>
" forward one character
:cnoremap <C-F> <Right>
" recall newer command-line
:cnoremap <C-N> <Down>
" recall previous (older) command-line
:cnoremap <C-P> <Up>
" back one word
:cnoremap <Esc><C-B> <S-Left>
" forward one word
:cnoremap <Esc><C-F> <S-Right>
" ===
" === Functions
" ===
autocmd VimEnter * silent! NoMatchParen
function! TrimWhitespace()
let l:save = winsaveview()
keeppatterns %s/\s\+$//e
call winrestview(l:save)
endfun
autocmd BufWritePre * silent! :call TrimWhitespace()
function! InsertOnTerminal()
if &buftype ==# "terminal"
normal i
endif
endfunction
autocmd! BufEnter * call InsertOnTerminal()
if has('nvim')
autocmd! TermOpen * call InsertOnTerminal()
endif