summaryrefslogtreecommitdiff
path: root/.config/vim/.vimrc
blob: b8f2f15f4147c6280e15282eb7cf02469619d615 (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
runtime ftplugin/man.vim
set runtimepath^=$HOME/.config/vim/.vim
set viminfo=
set number
set relativenumber
set title
set bg=dark
set go=a
set mouse=a
set nohlsearch
set clipboard+=unnamedplus
set noshowmode
set noruler
set laststatus=0
set noshowcmd
set nocompatible
set autoindent
set cindent
set smartindent
set nowrap
set ignorecase
set smartcase
set laststatus=2
set incsearch
set wildignore=*.o,*.obj,*.bak,*.exe

" Use pathogen (plugin manager)

filetype off
execute pathogen#infect()
execute pathogen#helptags()
syntax on
filetype plugin on
filetype plugin indent on

" Automatically source .vimrc after saving
autocmd BufWritePost ~/.vimrc source $MYVIMRC

" Automatically source .inputrc after saving
autocmd BufWritePost ~/.inputrc !bind -f ~/.inputrc

" Automatically deletes all trailing whitespace and newlines at end of file on save. & reset cursor position
autocmd BufWritePre * let currPos = getpos(".")
autocmd BufWritePre * %s/\s\+$//e
autocmd BufWritePre * %s/\n\+\%$//e
autocmd BufWritePre * cal cursor(currPos[1], currPos[2])

" Mappings
noremap <BS> dBx
nnoremap s o<Esc>kzz
nnoremap S O<Esc>jzz
nnoremap Y y$
nnoremap - ddp
nnoremap _ ddkP
nnoremap <C-J> "+yy
nnoremap <C-W> "+yW
nnoremap <C-K> "+p
nnoremap <space> i<space><esc>
nnoremap <silent> <F7> :tabnew ~/.vimrc<CR>
nnoremap <silent> <F8> :TlistToggle<CR>
nnoremap <silent> <F9> :NERDTree<CR>
inoremap <Space><Space> <Esc>/<++><CR>"_c4l
vnoremap <C-J> "+y

" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab

" Automatically use black on a Python file
autocmd BufWritePost *.py !black --line-length=79  %

" Pymode config
let g:pymode = 1
let g:pymode_warnings = 0
let g:pymode_trim_whitespaces = 1
let g:pymode_options = 1
let g:pymode_options_max_line_length = 79
let g:pymode_options_colorcolumn = 1
let g:pymode_indent = 1
let g:pymode_indent_hanging_width = &shiftwidth
let g:pymode_indent_hanging_width = 4
let g:pymode_doc = 1