-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
119 lines (99 loc) · 3.28 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
" This must be first, because it changes other options as side effect
" Also, better safe than sorry: http://stackoverflow.com/a/5845583/2752041
set nocompatible
" Executing Pathogen
execute pathogen#infect()
" Disable Swap files (be sure to always save your work!)
set noswapfile
" Remapping : to ; so you can skip pressing <Shift> to enter command mode
nnoremap ; :
" Indentation
set expandtab
set shiftwidth=2
set shiftround
set softtabstop=2
set autoindent
" Ignores case if search is all lowercase, case-sensitive otherwise
set smartcase
" Enabling indentation and plugins for specific files
filetype plugin indent on
" Open new split windows to the right/bottom
set splitbelow
set splitright
" Skip C-W keystroke for pane navigation
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" Expanding undo and history actions
set history=600
set undolevels=600
" Enables paste mode on insert (ignores formatting smarts)
set pastetoggle=<F2>
" <Plugin>NERDTree Keymaps
nmap <C-k><C-l> :NERDTreeToggle<CR>
nmap <C-l><C-k> :NERDTreeToggle<CR>
let NERDTreeQuitOnOpen=1
" Setting color scheme and syntax highlight
" <http://nvie.com/posts/how-i-boosted-my-vim/#enable-syntax-highlighting>
if &t_Co > 2 || has("gui_running")
syntax on
if &t_Co >= 256
" Remember to execute 'TERM=xterm-256color' in your shell's .rc
" (~/.bashrc)
colorscheme mustang
end
endif
" Function to toggle between absolute and relative line numbers
" <http://jeffkreeftmeijer.com/2012/relative-line-numbers-in-vim-for-super-fast-movement>
function! NumberToggle()
if(&relativenumber == 1)
set number
else
set relativenumber
endif
endfunc
nnoremap <C-n> :call NumberToggle()<cr>
" Setting number and calling toggle upon loading. For Vim 7.4+ both work together
" so there is no need to swtich between each.
set number
call NumberToggle()
" Automatically toggles when entering/leaving insert mode
autocmd InsertEnter * :set number
autocmd InsertLeave * :set relativenumber
" Saves and loads current session on VimEnter and VimLeave
" Sessions are stored at ~/.vim/sessions (ignored by Git)
" http://stackoverflow.com/a/31978241/2752041
function! MakeSession()
let b:sessiondir = $HOME . "/.vim/sessions" . getcwd()
if (filewritable(b:sessiondir) != 2)
exe 'silent !mkdir -p ' b:sessiondir
redraw!
endif
let b:filename = b:sessiondir . '/session.vim'
exe "mksession! " . b:filename
endfunction
function! LoadSession()
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
endfunction
if(argc() == 0)
au VimEnter * nested :call LoadSession()
endif
au VimLeave * :call MakeSession()
" No arrow keys allowed!!! (╯°□°)╯︵ ┻━┻)
" This is really good to enforce the use of HJKL keys for navigation.
" You may seriously consider disabling (commenting these lines) if you're just
" getting started with Vim.
" Also, try <http://vim-adventures.com> to help you get used to Vim navigation.
map <up> <nop>
map <down> <nop>
map <left> <nop>
map <right> <nop>
" Allows you to save files that requires sudo permission after you foolishly opened it without sudo
cmap w!! w !sudo tee % >/dev/null