-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
68 lines (56 loc) · 1.62 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
" Don't need the mouse in console.
set mouse=
set showcmd
set background=light
set laststatus=2
" Sync default vim clipboard with system
set clipboard=unnamedplus
setlocal cm=blowfish2
set wildmenu
set wcm=<Tab>
menu Encoding.koi8-r :e ++enc=koi8-r<CR>
menu Encoding.cp1251 :e ++enc=cp1251<CR>
menu Encoding.cp866 :e ++enc=cp866<CR>
menu Encoding.ucs-2le :e ++enc=ucs-2le<CR>
menu Encoding.utf-8 :e ++enc=utf-8<CR>
map <F12> :emenu Encoding.<Tab>
au BufNewFile,BufRead *.yaml,*.yml so ~/.vim/yaml.vim
set splitbelow
set splitright
" Creates a session
function! MakeSession()
let b:sessiondir = $HOME . "/.vim/sessions" . getcwd()
if (filewritable(b:sessiondir) != 2)
exe 'silent !mkdir -p ' b:sessiondir
redraw!
endif
let b:sessionfile = b:sessiondir . '/session.vim'
exe "mksession! " . b:sessionfile
endfunction
" Updates a session, BUT ONLY IF IT ALREADY EXISTS
function! UpdateSession()
let b:sessiondir = $HOME . "/.vim/sessions" . getcwd()
let b:sessionfile = b:sessiondir . "/session.vim"
if (filereadable(b:sessionfile))
exe "mksession! " . b:sessionfile
echo "updating session"
endif
endfunction
" Loads a session if it exists
function! LoadSession()
if argc() == 0
let b:sessiondir = $HOME . "/.vim/sessions" . getcwd()
let b:sessionfile = b:sessiondir . "/session.vim"
if (filereadable(b:sessionfile))
exe 'source ' b:sessionfile
else
echo "No session loaded."
endif
else
let b:sessionfile = ""
let b:sessiondir = ""
endif
endfunction
au VimEnter * nested :call LoadSession()
au VimLeave * :call UpdateSession()
map <leader>m :call MakeSession()<CR>