Skip to content

Instantly share code, notes, and snippets.

@yutarot
Last active July 10, 2018 17:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yutarot/ceac1b4ec13bb7268243915168767a0d to your computer and use it in GitHub Desktop.
Save yutarot/ceac1b4ec13bb7268243915168767a0d to your computer and use it in GitHub Desktop.
.vimrc for my environment. Basically I prefer minimal configurations so that I can use it for more environments.
"" Display
set title
set number
set showcmd
set showmode
set laststatus=2
set statusline+=%{matchstr(hostname(),'\\w\\+')}@
set statusline+=%<%F
set statusline+=%m
set statusline+=%r
set statusline+=%h
set statusline+=%w
set statusline+=[%{&fileformat}]
set statusline+=[%{has('multi_byte')&&\&fileencoding!=''?&fileencoding:&encoding}]
set statusline+=%y
set statusline+=%=
"set statusline+=[C=%c/%{col('$')-1}]
"set statusline+=[L=%l/%L]
set statusline+=[%p%%]
"" Edit
set fenc=utf-8
set fileformats=unix,dos,mac
if has('unix')
set fileformat=unix
set fileformats=unix,dos,mac
set fileencoding=utf-8
set fileencodings=utf-8,iso-2022-jp,cp932,euc-jp
set termencoding=
elseif has('win32')
set fileformat=dos
set fileformats=dos,unix,mac
set fileencoding=utf-8
set fileencodings=iso-2022-jp,utf-8,euc-jp,cp932
set termencoding=
endif
set ambiwidth=double
set tabstop=2
set shiftwidth=2
set softtabstop=4
set autoindent
set smartindent
set list
"set listchars=tab:>-,trail:-,nbsp:%,extends:>,precedes:<,eol:<
set listchars=tab:»-,trail:-,eol:↲,extends:»,precedes:«,nbsp:%
set display=uhex
" treat `C-A``C-X` as decimal number
set nrformats=
set hidden
set history=50
set virtualedit=block
set backspace=indent,eol,start
set showmatch
set wildmenu
set wildmode=longest,full
set formatoptions+=mM
set nostartofline
set nowrap
set clipboard+=unnamed
"" Color
syntax on
colorscheme desert
" clear hilight search with 'Ctrl-L'
nnoremap <silent> <C-l> :<C-u>nohlsearch<CR><C-l>
"" Search
set ignorecase
set smartcase
set hlsearch
set nowrapscan
"" Cursor
" keep cursor middle of the window
set scrolloff=999
" move over line break
set whichwrap+=h,l,<,>,[,],b,s
"" netrw
" hide help message on the top
let g:netrw_banner = 0
" tree view
let g:netrw_liststyle = 3
" open a file on the right side
let g:netrw_altv = 1
" open a file with vsplit with 85% width
let g:netrw_winsize = 85
"" Other
" remove trailing white space when saving file
autocmd BufWritePre * :%s/\s\+$//ge
" `,date` in insert mode will insert current date
inoremap ,date <C-R>=strftime('%Y/%m/%d (%a)')<CR>
" `,time` in insert mode will insert current time
inoremap ,time <C-R>=strftime('%H:%M')<CR>
" `,sudo` in normal mode will save file as sudo command
nmap ,sudo :w !sudo tee %<CR>
" `C-C,C-D` will show the diff between before and after the edit
nmap <C-C><C-D> :w !diff -u % -<CR>
" `C-W,e` will open file browser as vertical
nmap <C-W>e :vsp<CR>:wincmd w<CR>:e! ./<CR>
" `C-W,E` will open file window as horizontal
nmap <C-W>E :sp<CR>:wincmd w<CR>:e! ./<CR>
" `C-W,C-A` will just show the current file
nmap <C-W><C-A> :all<CR>
" `,cd` in normal mode will translfer to the directory which keep the file now I'm editing
nmap ,cd :cd %:h<CR>
" `C-L` will call awk
nmap <C-C><C-L> :w !awk 'BEGIN{n=0}{n+=$1}END{print n}'
" `C-W,o` will devide window horizontally
nmap <C-W>o :sp
" `C-W,O` will devide window vertically
nmap <C-W>O :vsp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment