commit 2ec332f503eafba60e70c413863febb8b487be11
parent 696acfe8873263c8484301fa69e23539abd4e66a
Author: Alex Balgavy <a.balgavy@gmail.com>
Date: Fri, 27 Jul 2018 19:02:26 +0200
Modularised vimrc
Now sourced through separate files. To use, symlink vim-config (target) to $HOME/.config/vim-config (link) and symlink $HOME/.config/vim-config/init.vimrc (target) to ~/.vimrc (link).
Diffstat:
6 files changed, 161 insertions(+), 157 deletions(-)
diff --git a/vim-config/commands.vimrc b/vim-config/commands.vimrc
@@ -0,0 +1,17 @@
+" Custom commands
+command Todo vimgrep /TODO\C/ **/*.* | copen
+command Note vimgrep /NOTE\C/ **/*.* | copen
+command Fix vimgrep /FIXME\C/ **/*.* | copen
+command CDC cd %:p:h
+command Maketab set noet ts=2 | %retab!
+command Diff w !diff % -
+command Diffc w !git diff % -
+function! InsertTabWrapper()
+ let col = col('.') - 1
+ if !col || getline('.')[col - 1] !~ '\k'
+ return "\<tab>"
+ else
+ return "\<c-p>"
+ endif
+endfunction
+
diff --git a/vim-config/editor.vimrc b/vim-config/editor.vimrc
@@ -0,0 +1,63 @@
+" Highlight current line
+set cursorline
+
+" Text wrap sucks
+set nowrap
+
+" Linebreak when obsessive
+set lbr
+set tw=500
+
+" Numbered lines
+set number
+set numberwidth=3
+
+" I want spaces
+set expandtab
+
+" with a smart tab
+set smarttab
+
+" and 1 tab == 4 spaces
+set shiftwidth=4
+set softtabstop=4
+set shiftround
+set copyindent
+
+" Auto indent
+set ai
+
+" Smart indent
+set si
+
+" Folding
+set foldmethod=indent
+
+" Status bar
+set laststatus=2
+set statusline=\ %F%m\%r%h\ %w
+set statusline+=\ \ CWD:\ %r%{getcwd()}%h
+set statusline+=%=%l,%c
+set statusline+=\ \ B%n
+
+" Show matching brackets
+set showmatch
+set mat=2
+
+" Searching
+set ignorecase
+set hlsearch
+set incsearch
+set smartcase
+
+" Set 80-char column (off by default)
+" set colorcolumn=80
+highlight ColorColumn ctermbg=233
+
+" Backspace tweaks
+set backspace=indent,eol,start
+set whichwrap+=<,>,h,l
+
+" How to split new windows
+set splitbelow splitright
+
diff --git a/vim-config/general.vimrc b/vim-config/general.vimrc
@@ -0,0 +1,43 @@
+"====== GENERAL ======"
+" Update file when changed from the outside
+set autoread
+
+" For editing binaries
+set binary
+
+" No swp please, I save all the time
+set noswapfile
+
+" Hide buffers instead of closing
+set hidden
+
+" Dont redraw while executing macros
+set lazyredraw
+
+" Encoding
+set encoding=utf-8 nobomb
+set fileencoding=utf-8
+set fileencodings=utf-8
+set fileformats=unix,dos,mac
+
+" Hide the annoying banner in netrw explorer
+let g:netrw_banner = 0
+
+" Send more characters at a given time
+set ttyfast
+
+" Show partial command on last line
+set showcmd
+
+" ======= Colors and Fonts ======== "
+" Syntax highlighting
+syntax on
+
+" Enable dark background
+set background=dark
+
+" Enable 256 colormode
+set t_Co=256
+
+" Mouse tweak
+set mousemodel=popup
diff --git a/vim-config/init.vimrc b/vim-config/init.vimrc
@@ -0,0 +1,4 @@
+source $HOME/.config/vim-config/general.vimrc
+source $HOME/.config/vim-config/editor.vimrc
+source $HOME/.config/vim-config/commands.vimrc
+source $HOME/.config/vim-config/map.vimrc
diff --git a/vim-config/map.vimrc b/vim-config/map.vimrc
@@ -0,0 +1,34 @@
+let mapleader="," " Set the mapleader to be ,
+
+" So I don't have to mash shift all the time
+nnoremap ; :
+
+" Fat finger fixes
+cnoreabbrev W! w!
+cnoreabbrev Q! q!
+cnoreabbrev Qall! qall!
+cnoreabbrev Wq wq
+cnoreabbrev Wa wa
+cnoreabbrev wQ wq
+cnoreabbrev WQ wq
+cnoreabbrev W w
+cnoreabbrev Q q
+cnoreabbrev Qall qall
+map q: <Nop>
+
+" Custom mappings
+nnoremap <leader>dif :Diff<cr>
+nnoremap <leader>/ :noh<cr>
+inoremap <expr> <tab> InsertTabWrapper()
+inoremap <s-tab> <c-n>
+
+" Retain visual mode after > and <
+vmap < <gv
+vmap > >gv
+
+" Move visual block
+vnoremap J :m '>+1<cr>gv=gv
+vnoremap K :m '<-2<cr>gv=gv
+
+" stfu and write the file
+cmap w!! w !sudo tee > /dev/null %
diff --git a/vimrc b/vimrc
@@ -1,157 +0,0 @@
-"====== GENERAL ======"
-" Update file when changed from the outside
-set autoread
-
-" For editing binaries
-set binary
-
-" No swp please, I save all the time
-set noswapfile
-
-" Hide buffers instead of closing
-set hidden
-
-" Dont redraw while executing macros
-set lazyredraw
-
-" Encoding
-set encoding=utf-8 nobomb
-set fileencoding=utf-8
-set fileencodings=utf-8
-set fileformats=unix,dos,mac
-
-" Hide the annoying banner in netrw explorer
-let g:netrw_banner = 0
-
-" Send more characters at a given time
-set ttyfast
-
-" Show partial command on last line
-set showcmd
-
-" ======= Colors and Fonts ======== "
-" Syntax highlighting
-syntax on
-
-" Enable dark background
-set background=dark
-
-" Enable 256 colormode
-set t_Co=256
-
-" Mouse tweak
-set mousemodel=popup
-
-"====== EDITOR ======"
-" Highlight current line
-set cursorline
-
-" Text wrap sucks
-set nowrap
-
-" Linebreak when obsessive
-set lbr
-set tw=500
-
-" Numbered lines
-set number
-set numberwidth=3
-
-" I want spaces
-set expandtab
-
-" with a smart tab
-set smarttab
-
-" and 1 tab == 4 spaces
-set shiftwidth=4
-set softtabstop=4
-set shiftround
-set copyindent
-
-" Auto indent
-set ai
-
-" Smart indent
-set si
-
-" Folding
-set foldmethod=indent
-
-" Status bar
-set laststatus=2
-
-" Show matching brackets
-set showmatch
-set mat=2
-
-" Searching
-set ignorecase
-set hlsearch
-set incsearch
-set smartcase
-
-" Set 80-char column (off by default)
-" set colorcolumn=80
-highlight ColorColumn ctermbg=233
-
-" Backspace tweaks
-set backspace=indent,eol,start
-set whichwrap+=<,>,h,l
-
-" How to split new windows
-set splitbelow splitright
-
-"====== COMMANDS ======"
-let mapleader="," " Set the mapleader to be ,
-
-" So I don't have to mash shift all the time
-nnoremap ; :
-
-" Fat finger fixes
-cnoreabbrev W! w!
-cnoreabbrev Q! q!
-cnoreabbrev Qall! qall!
-cnoreabbrev Wq wq
-cnoreabbrev Wa wa
-cnoreabbrev wQ wq
-cnoreabbrev WQ wq
-cnoreabbrev W w
-cnoreabbrev Q q
-cnoreabbrev Qall qall
-map q: <Nop>
-
-" Custom mappings
-nnoremap <leader>dif :Diff<cr>
-nnoremap <leader>/ :noh<cr>
-inoremap <expr> <tab> InsertTabWrapper()
-inoremap <s-tab> <c-n>
-
-" Custom commands
-command Todo vimgrep /TODO\C/ **/*.* | copen
-command Note vimgrep /NOTE\C/ **/*.* | copen
-command Fix vimgrep /FIXME\C/ **/*.* | copen
-command CDC cd %:p:h
-command Maketab set noet ts=2 | %retab!
-command Diff w !diff % -
-command Diffc w !git diff % -
-function! InsertTabWrapper()
- let col = col('.') - 1
- if !col || getline('.')[col - 1] !~ '\k'
- return "\<tab>"
- else
- return "\<c-p>"
- endif
-endfunction
-
-
-" Retain visual mode after > and <
-vmap < <gv
-vmap > >gv
-
-" Move visual block
-vnoremap J :m '>+1<cr>gv=gv
-vnoremap K :m '<-2<cr>gv=gv
-
-" stfu and write the file
-cmap w!! w !sudo tee > /dev/null %