forked from cspeterson/dotfiles
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
148 lines (132 loc) · 4.33 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
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
"###############################################3
"## General goodness
"###############################################3
set nu " line numbers
set term=xterm-256color " behave sensibly
set cursorline " highlight the line being edited
set scrolloff=3 " keep 3 lines above or below when scrolling up and down
set spell spelllang=en_us " spellcheck on
" " Toggles
set pastetoggle=<F2>
" Spell check
nnoremap <F4> :setlocal spell! spelllang=en_us<CR>
" Toggle whitespace char representation
nnoremap <C-l> :set list!<CR>
" Toggle nu
nnoremap <C-n> :set number!<CR>
" Registers
" map register c to x11 'clipboard' register because "+ is more work
map "c "+
" Search
" Use ignore case, smart case, highlight results, incrementally
" smart case ignores "ignore case" if we include uppercase characters
set ignorecase
set smartcase
set hlsearch
set incsearch
nnoremap <CR> :nohlsearch<cr> " enter clears search highlighting
" Navigation
nmap <C-Up> 4k
nmap <C-Down> 4j
" Statusline
set laststatus=2 " always show status line
set statusline=
" Buffer number
set statusline+=Buf:%(%{&filetype!='help'?bufnr('%'):''}\ \|\ %)
" Add full expanded path (without filename) of file, cut from right at 30 chars
set statusline+=%.30{fnamemodify(bufname('%'),':p:h')}/
" Add filename
set statusline+=%t
" Add modified or RO marker after filename if either true
set statusline+=%{&modified?'\ +\ ':''}
set statusline+=%{&readonly?'\ 🔒\ ':''}
" From here, align the rest to the right
set statusline+=%=
" Paste?
set statusline+=%{&paste?'paste':'nopaste'}
set statusline+=\ \|
set statusline+=%{&spell?'spell':'nospell'}
set statusline+=\ \|
" Character value
set statusline+=\ A:%b\ U\+%B
set statusline+=\ \|\
" File type as detected by vim, specifying when none
set statusline+=[%{&filetype!=#''?&filetype:'none'}]
" Show file encoding ig
set statusline+=%(\ \|%{(&bomb\|\|&fileencoding!~#'^$\\\|utf-8'?'\ '.&fileencoding.(&bomb?'-bom':''):'')\.(&fileformat!=#(has('win32')?'dos':'unix')?'\ '.&fileformat:'')}%)
" Show `et` or `noet` for expandtab on/off. Then, shift width
set statusline+=%(\ \|\ %{&modifiable?(&expandtab?'et\ ':'noet\ ').&shiftwidth:''}%)
" Column number
set statusline+=\ \|\ Col:\ %{&number?'':printf('%2d,',line('.'))}
set statusline+=%-2v " Virtual column number if differs
" Percentage through file
set statusline+=\ \|\ %2p%%
" Total lines
set statusline+=/%L
" Layouts
set splitbelow " when splitting layout, new horizontal splits go below
set splitright " when splitting layout, new vert splits go to the rights
" Tab nav controls sorta in the vein of Firefox etc
" Not using Ctrl-Tab etc because X and/or the terminal don't let the ind. keys
" through :(
nnoremap <S-Tab> :tabprevious<CR>
nnoremap <Tab> :tabnext<CR>
nnoremap <C-t> :tabnew<CR>
" Redundant mappings for common functions because I always typo
" split
command Sp sp
command SP sp
" quit all
command Q q
command Qa qa
command QA qa
" split vert
command VSp sp
command VSP sp
command VsP sp
" write/save/quit
command W w
command Wq wq
command WQ wq
command Wqa wqa
command WQa wqa
command WQA wqa
" Saving if forgot sudo
cmap w!! w !sudo tee > /dev/null %
" Code folding
set foldmethod=indent
set foldlevel=99
nnoremap <space> za
"###############################################3
""## My functions or long-form commands
"###############################################3
" Exi - "execute interactive"
" A command to execute whatever follows in an interactive shell
" Ensure shell flags specify interactive mode, execute command, and return
" to original setting
" Basically I just want to be able to execute bash aliases once in a while
" Use example:
" :Exi %!myalias arg1 arg2
command -nargs=+ Exi
\ let shellcmdflag_orig = &shellcmdflag |
\ let &shellcmdflag='-ci' |
\ execute ':' . "<args>" |
\ let &shellcmdflag=shellcmdflag_orig
" Jdate - "jekyll date"
" 'Find your special Jekyll datestring' and insert after the cursor
command Jdate call Jekyll_date()
function Jekyll_date()
let regbak = @n
let @n = strftime('%Y-%m-%d %H:%M:%S %z')
normal! "np
let @n = regbak
endfunction
"###############################################3
"## Plugins!
"###############################################3
source ~/.vim_plugins
"###############################################3
"## After plugins!
"###############################################3
" This needs to come well after Vundle does its thing
filetype plugin indent on