-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.vimrc
More file actions
103 lines (87 loc) · 2.44 KB
/
.vimrc
File metadata and controls
103 lines (87 loc) · 2.44 KB
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
if has("gui_running")
language messages en
set guifont=Consolas:h9:cANSI
set langmenu=en_US.UTF-8
set guioptions-=T
" easy copy-paste
vnoremap <C-c> "+y
inoremap <C-v> <Esc>"+pa
endif
" options
syntax on
colorscheme desert
filetype plugin on
set enc=utf-8
set mouse=a
set autoindent
set tabstop=2
set shiftwidth=2
set bs=2
set noswapfile
set number
set nowrap
set smartcase
set incsearch
" window movement
noremap <C-Left> <C-w>h
noremap <C-Right> <C-w>l
noremap <C-Up> <C-w>k
noremap <C-Down> <C-w>j
inoremap <C-Left> <Esc><C-w>h
inoremap <C-Right> <Esc><C-w>l
inoremap <C-Up> <Esc><C-w>k
inoremap <C-Down> <Esc><C-w>j
" move lines
nnoremap <A-Up> :m .-2<CR>==
nnoremap <A-Down> :m .+1<CR>==
inoremap <A-Up> <Esc>:m .-2<CR>==i
inoremap <A-Down> <Esc>:m .+1<CR>==i
vnoremap <A-Up> :m '<-2<CR>gv=gv
vnoremap <A-Down> :m '>+1<CR>gv=gv
" utils
noremap <F3> :buffers<CR>:buffer<Space>
noremap <F4> :sh<CR>
" run current file
nnoremap <F5> :!@%<CR>
" easy find and open file (use <Tab> to cycle)
noremap <C-c><C-f> :e **/
inoremap <C-c><C-f> <Esc>:e **/
" tab management
noremap <leader>t :tabedit .<cr>
noremap <leader>w :tabclose<cr>
" surround
vnoremap ' <Esc>`<i'<Esc>`>a'<Esc>
vnoremap " <Esc>`<i"<Esc>`>a"<Esc>
vnoremap ( <Esc>`<i(<Esc>`>a)<Esc>
vnoremap { <Esc>`<i{<Esc>`>a}<Esc>
vnoremap [ <Esc>`<i[<Esc>`>a]<Esc>
" auto-closing characters
inoremap <expr> " strpart(getline('.'), col('.')-1, 1) == "\"" ? "\<Right>" : "\"\"\<Left>"
inoremap <expr> ' strpart(getline('.'), col('.')-1, 1) == "\'" ? "\<Right>" : "\'\'\<Left>"
inoremap ( ()<Left>
inoremap <expr> ) strpart(getline('.'), col('.')-1, 1) == ")" ? "\<Right>" : ")"
inoremap { {}<Left>
inoremap <expr> } strpart(getline('.'), col('.')-1, 1) == "}" ? "\<Right>" : "}"
inoremap [ []<Left>
inoremap <expr> ] strpart(getline('.'), col('.')-1, 1) == "]" ? "\<Right>" : "]"
inoremap < <><Left>
inoremap <expr> > strpart(getline('.'), col('.')-1, 1) == ">" ? "\<Right>" : ">"
" autocomplete
inoremap <C-Space> <C-x><C-o>
if has("autocmd")
autocmd BufNewFile,BufRead *.md set ft=markdown
autocmd BufNewFile,BufRead *.html.erb set ft=eruby.html
endif
" easy mappings
let mapleader=","
" Open new file in vertical split
nmap <leader>o :Vexplore! .<CR>
" Open new file in horizontal split
nmap <leader>h :Hexplore .<CR>
" Edit and source .vimrc
nmap <leader>ev :edit $MYVIMRC<CR>
nmap <leader>sv :source $MYVIMRC<CR>
" Change buffers
nmap <leader>. :bnext<CR>
nmap <leader>, :bprevious<CR>
nmap <leader>- :bwipeout<CR>