aboutsummaryrefslogtreecommitdiff
path: root/vimrc
blob: 6e593ca502368abc4c5b5b86ae87c96da6fdbfab (plain)
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
set nocompatible
set path+=**
set relativenumber
set smartcase
set ignorecase
set incsearch
set nowrap
set nobackup
set noswapfile
set autoread
set wildmenu
set autoindent
set encoding=utf8
set backspace=2
set scrolloff=4
set spelllang=en_us
set laststatus=2
set shiftwidth=4
set tabstop=4

filetype plugin on
filetype indent on

syntax enable

nnoremap <C-]> :bnext<cr>
nnoremap <C-[> :bprevious<cr>
nnoremap <C-b> :buffers<cr>:buffer 
nnoremap <C-p> :Explore<cr>
nnoremap <C-l> :Lex<cr>

" Commenting blocks of code.
augroup commenting_blocks_of_code
	autocmd!
	autocmd FileType c,cpp,go,scala   let b:comment_leader = '// '
	autocmd FileType sh,ruby,python   let b:comment_leader = '# '
	autocmd FileType conf,fstab       let b:comment_leader = '# '
	autocmd FileType lua              let b:comment_leader = '-- '
	autocmd FileType vim              let b:comment_leader = '" '
augroup END
noremap <silent> gcc :<C-B>silent <C-E>s/^/<C-R>=escape(b:comment_leader,'\/')<CR>/<CR>:nohlsearch<CR>
noremap <silent> gcu :<C-B>silent <C-E>s/^\V<C-R>=escape(b:comment_leader,'\/')<CR>//e<CR>:nohlsearch<CR>

" Go autoformat.
function! GoFmt()
	let file = expand('%')
	silent execute "!gofmt -w " . file
	edit!
endfunction
command! GoFmt call GoFmt()
augroup go_autocmd
	autocmd BufWritePost *.go GoFmt
augroup END