-
Notifications
You must be signed in to change notification settings - Fork 0
/
.vimrc
123 lines (96 loc) · 3.23 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
" Assigned - dash as the leader character
let mapleader = '-'
" Shift round makes sure tabs are always even
set shiftround
" Adds line numbers
set number
" Turns off line wrap
set nowrap
" Turn on syntax highlighting
syntax on
" Set auto indent
set autoindent
" Set spell checking on
set spell spelllang=en_us
" Tab settings
set shiftwidth=4
set softtabstop=4
set expandtab
" Set status line to always show
set laststatus=2
" Set linebreak on so that when wrap is on
" the break happens at a word
set linebreak
" Set 80 column color line
set colorcolumn=80
" Move lines up and down using leader j and k
noremap <leader>j ddp
noremap <leader>k ddkP
" Open vimrc for editing
nnoremap <leader>ev :vsplit $MYVIMRC<cr>
" Source current MYVIMRC
nnoremap <leader>sv :source $MYVIMRC<cr>
" Add single quotes to everything after = sign
nnoremap <leader>' F=wi'<esc>'<esc>g_a'<esc>
" Add single quote before and after the selected
" visual text
vnoremap <leader>' <esc>`<i'<esc>`>ea'<esc>
" Remap H and L to move to the beginning and end of the line
nnoremap H 0
nnoremap L $
" Remap Esc to qj
inoremap qj <esc>
" If your having trouble with a remap just disable the
" old one with the below line. This line makes the escape
" key a nop.
" inoremap <esc> <nop>
" Map shift tab to decrement tab
inoremap <S-Tab> <C-d>
augroup MyGroup
" Clear the autocmds of the current group so the
" don't get piled up if the vimrc is reloaded
autocmd!
" Autocmds for Python
" Add autocmd to remove trailing white space
autocmd FileType python autocmd BufWritePre <buffer> %s/\s\+$//e
" Execute Python files with leader p
autocmd FileType python nnoremap <leader>p terminal python %:p
autocmd FileType python setlocal expandtab
autocmd FileType python setlocal commentstring=#\ %s
" Set Rules for make files
autocmd FileType make setlocal tabstop=4 softtabstop=0 noexpandtab
" Set rules for vim files
autocmd FileType vim setlocal noexpandtab
autocmd FileType vim setlocal commentstring=\"\ %s
" Set rules for bash files
autocmd FileType sh setlocal commentstring=#\ %s
augroup END
" The below function and group are copied mostly from the below URL on stack
" overflow https://vi.stackexchange.com/a/35172
" The function and group edit the highlighting for the spelling module.
" I makes it so that incorrect words are underlined and the color is
" change rather than coloring them with a background color.
" I really want only the underline to be colored differently but apparently
" that is a relatively new feature so check back on that in the future.
function! MyHighlights() abort
hi clear SpellBad
hi SpellBad cterm=underline ctermfg=197
hi clear SpellLocal
hi SpellLocal cterm=underline ctermfg=197
endfunction
augroup MyColors
autocmd!
autocmd ColorScheme * call MyHighlights()
autocmd VimEnter * nested colorscheme default
augroup END
" Command to trim trailing whitespace
nnoremap <leader>tt :%s/\s\+$//e<cr>
" Makes current word case. One map for insert mode and the other for normal mode
inoremap <leader><c-u> <esc>viwUA
nnoremap <leader><c-u> viwU
" Add abbreivation for my name
iabbrev myname Christopher Nyland
" add abbreivation for my email
iabbrev myemail [email protected]
" add abbreviation to fix common mispelling teh
iabbrev teh the