summaryrefslogtreecommitdiff
path: root/.vimrc
blob: 60ca2c83cead00b5264878eb013a3417cc230486 (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
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
" General
set nocompatible
set autoread
set hidden
set showmode
set showcmd
set number
set history=1000
set gcr=a:blinkon0
set grepprg="grep -nH $*"
let g:tex_flavor = "latex"
set laststatus=2
set visualbell
set background=dark
set runtimepath=~/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,~/.vim/after
set autowrite
set autoread
set ttyfast
syntax on

" Make search better
set gdefault
set ignorecase
set smartcase
set hlsearch
noremap <silent> <Leader>, :noh<cr>
set incsearch
set showmatch

" X11 clipboard support
set pastetoggle=<F2> "to preserve indentation
vnoremap <C-c> "*y
map <silent><Leader>p :set paste<CR>o<esc>"*]p:set nopaste<cr>"
map <silent><Leader><S-p> :set paste<CR>O<esc>"*]p:set nopaste<cr>"

" Disable folding
set nofoldenable

" Put swap files into a tmp directory
set directory^=$HOME/.vim/tmp//

" Spellcheck
function! ToggleSpell()
        setlocal spell!
        if &spell
                echo "Spellcheck ON"
        else
                echo "Spellcheck OFF"
        endif
endfunction

" Indentation
set autoindent
set smartindent
set smarttab
set shiftwidth=8
set softtabstop=8
set tabstop=8
set expandtab
filetype plugin on
filetype indent on
noremap p p=`[<C-o>
noremap P P=`[<C-o>

" Per-project indentation
au BufRead,BufEnter ~/repositories/linux/*.{c,h} set noexpandtab

set nowrap
set linebreak

set splitbelow
set splitright

" NERDTree stuffs
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
let g:NERDTreeDirArrowExpandable = ''
let g:NERDTreeDirArrowCollapsible = ''
let NERDTreeIgnore = ['\.o$','\.so$','\.class$','\.png$','\.jpg$','\.d$']

" Completion
set wildmode=list:longest
set wildmenu
set wildignore=*.o,*.obj,*~
set wildignore+=vim/backups
set wildignore+=*sass-cache*
set wildignore+=*DS_Store*
set wildignore+=vendor/cache/**
set wildignore+=log/**
set wildignore+=tmp/**
set wildignore+=*.png,*.jpeg,*.gif
set wildignore+=*/tmp/*,*.so,*.swp,*.zip

" Ctrlp
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
let g:ctrlp_working_path_mode = 'ra'
let g:ctrlp_user_command = 'find %s -type f'
let g:ctrlp_custom_ignore = '\v[\/]\.(git|hg|svn)$'
let g:ctrlp_custom_ignore = {
        \'dir':        '\v[\/]\.(git|hg|svn)$',
        \'file':       '\v\.(exe|so|dll)$',
        \ }

" Scrolling
set scrolloff=8
set sidescrolloff=15
set sidescroll=1

" Key mapping
no <Up> <Nop>
no <Down> <Nop>
no <Left> <Nop>
no <Right> <Nop>
no <Delete> <Nop>
ino <Up> <Nop>
ino <Down> <Nop>
ino <Left> <Nop>
ino <Right> <Nop>
ino <Delete> <Nop>
vno <Up> <Nop>
vno <Down> <Nop>
vno <Left> <Nop>
vno <Right> <Nop>
vno <Delete> <Nop>
nmap <Leader>s :source ~/.vimrc<CR>
vnoremap <C-X> <Esc>`.``gvP``P
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>
nnoremap <silent> <Leader>n :NERDTreeToggle<CR>
nnoremap <silent> <Leader>c :silent !ctags -R .<CR><C-L>
nnoremap <silent> <Leader>t :tag 
nnoremap <silent> <F5> :call ToggleSpell()<CR>
let mapleader = " "

" Email options
au BufRead /tmp/mutt-* set tw=72