aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSukma Wardana <hey@swardana.com>2020-11-09 18:45:11 +0700
committerSukma Wardana <hey@swardana.com>2020-11-09 18:45:11 +0700
commit602b69b5abd8f89312570325724bacd53ac64f24 (patch)
treed082c467ce2c63dc33e171f75c1abc33d4578219
parentfe09e9588ca7957a873eb87c1c529af57890907a (diff)
downloaddotfiles-602b69b5abd8f89312570325724bacd53ac64f24.tar.gz
dotfiles-602b69b5abd8f89312570325724bacd53ac64f24.zip
Add vimrc
Signed-off-by: Sukma Wardana <hey@swardana.com>
-rw-r--r--CHANGELOG1
-rw-r--r--vimrc211
2 files changed, 212 insertions, 0 deletions
diff --git a/CHANGELOG b/CHANGELOG
index ec2f1e8..1ff2dce 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -9,3 +9,4 @@ and this project adheres to https://semver.org/spec/v2.0.0.html.
- Add aliases.
- Add bash run commands and profile.
+- Add vimrc.
diff --git a/vimrc b/vimrc
new file mode 100644
index 0000000..2487e25
--- /dev/null
+++ b/vimrc
@@ -0,0 +1,211 @@
+# Copyright 2020 Sukma Wardana <hey@swardana.com>
+#
+# Redistribution and use of this script, with or without modification, is
+# permitted provided that the following conditions are met:
+#
+# 1. Redistributions of this script must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# Require vim 7.0 or newer.
+# Copy this file to home directory.
+# cp vimrc ~/.vimrc
+#
+
+" Set an environment variable for the user runtime directory.
+if !exists('$MYVIMRUNTIME')
+ if has('win32') || has('win64')
+ let $MYVIMRUNTIME = expand('~/vimfiles')
+ else
+ let $MYVIMRUNTIME = expand('~/.vim')
+ endif
+endif
+
+" Support older version of Vim that don't have autocmd.
+if has('autocmd')
+ let g:maplocalleader = ','
+ filetype plugin indent on " Auto detect filetype by filename extension and contents.
+endif
+
+" Indent wrapped lines if supported.
+if exists('+breakindent')
+ set breakindent
+endif
+
+" Add completion options.
+if exists('+completeopt')
+ set completeopt+=longest " Insert longest common substring.
+ set completeopt+=menuone " Show the menu even if only one match.
+endif
+
+" Use UTF-8 if we can and env LANG didn't tell us not to.
+if has('multi_byte') && !exists('$LANG') && &encoding ==# 'latin1'
+ set encoding=utf-8
+endif
+
+" Don't load GUI menus; set here before GUI starts.
+if has('gui_running')
+ set guioptions+=M
+endif
+
+" No terminal mouse, even if we could.
+" The manual says to set 't_RV', but I don't like that.
+if exists('+ttymouse') && &ttymouse !=# ''
+ set ttymouse=
+endif
+
+" Options dependent on the syntax feature.
+if has('syntax')
+ " Use syntax highlighting.
+ if !exists('g:syntax_on')
+ syntax enable
+ endif
+
+ " Use colorscheme if using the GUI or have 256 colors.
+ if has('gui_running') || &t_Co >= 256
+ silent! colorscheme mustang
+ endif
+
+ " If colorscheme not found, then default with dark background.
+ if !exists('g:colors_name')
+ set background=dark
+ endif
+endif
+
+" The all-important default indent settings; filetypes to tweak.
+set autoindent " Use indent of previous line on new lines.
+set expandtab " Use spaces instead of tabs.
+set shiftwidth=4 " Indent with four spaces.
+set softtabstop=4 " Insert four spaces with tab key.
+
+" Let me backspace over pretty much anything.
+set backspace+=eol " Line breaks.
+set backspace+=indent " Spaces from 'autoindent'.
+set backspace+=start " The start of current insertion.
+
+" Prefer unix
+set fileformats+=unix
+set fileformats+=dos
+set fileformats+=mac
+
+" Refresh when a file is change from the outside.
+set autoread
+
+" Give a prompt instead of just rejecting risky :write, :saveas.
+set confirm
+
+" Allow buffers to have changes without being displayed.
+set hidden
+
+" Keep much more command and search history.
+set history=2000
+
+" Wildmenu settings; see also plugin/wildignore.vim.
+set wildmenu " Use wildmenu.
+set wildmode=list:longest " Tab press completes and lists.
+
+" Highlight completed searches; clear on reload.
+set hlsearch
+if 1
+ nohlsearch
+endif
+
+" Show search matches as I type my pattern.
+set incsearch
+
+" Don't redraw the screen during batch execution.
+set lazyredraw
+
+" Break lines at word boundaries.
+set linebreak
+
+" Display row/col and percentage.
+set ruler
+
+" Display relative line numbers.
+set relativenumber
+
+" Don't allow setting options via buffer content.
+set nomodeline
+
+" Use 80 text width column.
+set textwidth=80
+set colorcolumn=80
+
+" Treat numbers with a leading zero as decimal, not octal.
+set nrformats-=octal
+
+" Prefix wrapped rows with three dots
+set showbreak=...
+
+" No flashing or beeping at all.
+set visualbell t_vb=
+
+" Define extra 'list' display characters.
+set listchars+=extends:> " Unwrapped text to screen right.
+set listchars+=precedes:< " Unwrapped text to screen left.
+set listchars+=tab:>- " Tab characters, preserve width.
+set listchars+=trail:_ " Trailing spaces.
+set listchars+=nbsp:+ " Non-breaking spaces.
+
+" Turn off backup, most stuff on source control.
+set nobackup
+set nowritebackup
+set noswapfile
+set noundofile " Vim 7.3 have feature about persistent undo.
+
+" New window positioning.
+set splitbelow " Below the current window, not above.
+set splitright " Right of the current window, not left.
+
+" Disabled arrow key on normal and insert mode.
+inoremap <Up> <NOP>
+inoremap <Down> <NOP>
+inoremap <Left> <NOP>
+inoremap <Right> <NOP>
+noremap <Up> <NOP>
+noremap <Down> <NOP>
+noremap <Left> <NOP>
+noremap <Right> <NOP>
+
+" Turn off linewise keys. Normally, the `j' and `k' keys move the cursor down one entire line.
+" With line wrapping on, this can cause the cursor to actually skip a few lines on the screen
+" because it's moving from line N to line N+1 in the file.
+" I want this to act more visually -- I want `down' to mean the next line on the screen.
+nmap j gj
+nmap k gk
+
+" Efficient command shortcut, e.g: ;w to save instead :w.
+nnoremap ; :
+
+" Window navigation with Ctrl + navigation. Instead Ctrl + w then h/j/k/l. Use Ctrl + h/j/k/l.
+map <C-h> <C-w>h
+map <C-j> <C-w>j
+map <C-k> <C-w>k
+map <C-l> <C-w>lp
+
+" Stack normal/visual/select Ctrl-L to clear search highlight.
+nnoremap <silent> <C-L> :<C-U>nohlsearch<CR><C-L>
+vnoremap <silent> <C-L> :<C-U>nohlsearch<CR>gv<C-L>
+
+" \ev Quick open vimrc file.
+nmap <silent> <Leader>ev :e $MYVIMRC<CR>
+
+" \sv Quick reload vimrc file.
+nmap <silent> <Leader>sv :so $MYVIMRC<CR>
+
+" Apply sudo (when forgot) editing privilege file with :w!!.
+cmap w!! w !sudo tee % >/dev/null
+
+" Source any .vim files from ~/.vim/config
+runtime! config/*.vim