Skip to content

Instantly share code, notes, and snippets.

@bluekyu
Last active August 29, 2015 14:17
Show Gist options
  • Save bluekyu/7a901628bfeaac1570d8 to your computer and use it in GitHub Desktop.
Save bluekyu/7a901628bfeaac1570d8 to your computer and use it in GitHub Desktop.
bluekyu's .vimrc
"Author : Younguk Kim (bluekyu)
"Date : 2015-03-19
"The order of file encodings
if has("multi_byte_encoding")
set encoding=utf-8
endif
set fileencodings=ucs-bom,utf-8,euc-kr,latin1
"Show line number
set nu
"status bar
set laststatus=2
set statusline=%F\ %m%h%r%=\ [FORMAT=%{&ff},%{&fenc}]\ [TYPE=%Y]\ [BUF=%n/%{bufnr('$')}]\ [POS=%l,%v]\ [LEN=%L]\ [%p%%]
"Background color
set background=dark
"Tab key and space(Tab is 4 spaces)
set expandtab
set softtabstop=4
set shiftwidth=4
set autoindent
"See tabs characters except spaces
set list
if has("multi_byte_encoding")
set listchars=tab:→\
else
set listchars=tab:\|\
endif
"Exception in Makefile syntax
autocmd FileType make set noexpandtab
autocmd FileType make set softtabstop=8
autocmd FileType make set shiftwidth=8
"Indent plugin
filetype indent plugin on
"Syntax highlight
syntax on
"=== Unsupported Filetype ===
autocmd BufNewFile,BufRead wscript set filetype=python
autocmd BufNewFile,BufRead *.glsl,*.frag,*.vert set filetype=cpp
"Change .md filetype (originally modula2 except README.md)
autocmd BufNewFile,BufRead *.md set filetype=markdown
if version < 704
if version < 703
"markdown
autocmd BufNewFile,BufRead *.markdown,*.mdown,*.mkd,*.mkdn set filetype=markdown
endif
"json
autocmd BufNewFile,BufRead *.json set filetype=javascript
endif
"=== Comment key map (Ctrl+C, Ctrl+X) ===
"Python
autocmd FileType python map <C-c> :s/^/#/<CR>
autocmd FileType python map <C-x> :s/^[#]//<CR>
autocmd FileType python imap <C-c> #
"Java, C, C++ comment (//)
autocmd FileType c,cpp,java,javascript map <C-c> :s/^/\/\//<CR>
autocmd FileType c,cpp,java,javascript map <C-x> :s/^\/\///<CR>
autocmd FileType c,cpp,java,javascript imap <C-c> //
"css comment (/* */)
autocmd FileType css map <C-c> :s/^\(.*\)$/\/\* \1 \*\//<CR>
autocmd FileType css map <C-x> :s/^\([/(]\*\) \(.*\) \(\*[/)]\)$/\2/<CR>
autocmd FileType css imap <C-c> /* */<ESC>hhi
"xml, html comment (<!-- -->)
autocmd FileType xml,html map <C-c> :s/^\(.*\)$/<!-- \1 -->/<CR>
autocmd FileType xml,html map <C-x> :s/^\(<!--\) \(.*\) \(-->\)$/\2/<CR>
autocmd FileType xml,html imap <C-c> <!-- --><ESC>hhhi
autocmd FileType xml,html set matchpairs+=<:>
"LaTeX
autocmd FileType tex map <C-c> :s/^/%/<CR>
autocmd FileType tex map <C-x> :s/^[%]//<CR>
autocmd FileType tex imap <C-c> %
"=== Key Mapping ===
"Fast quit
noremap ,q <C-W>q
"Re-map semicolon and colon to switch into command mode
noremap ; :
"In normal mode, Change to one line copy
nnoremap "+y ^v$"+y
"Switch to shell
noremap <F4> :shell<CR>
"Switch to next window
noremap <F5> <C-W>w
"Switch to next buffer
noremap <F6> :bn<CR>
"ctags
noremap <F7> :pts <C-R><C-W><CR>
noremap <F8> :TlistToggle<CR>
"Tab and Shift-Tab
nnoremap <Tab> >>
nnoremap <S-Tab> <<
vnoremap <Tab> >gv
vnoremap <S-Tab> <gv
inoremap <S-Tab> <C-D>
"Function command
command ToUnix call Tounix()
command ToDos call Todos()
command ToUtf call Toutf()
command AsUtf call Asutf()
command AsNanum call Asnanum()
"Detect GVIM
if has("gui_win32")
"Windows GUI
set guifont=DeJaVu_Sans_Mono:h10:cANSI
colorscheme torte
"Window size
set lines=75 columns=140
set bs=2
set ff=unix
set encoding=utf-8
set guioptions-=l
set guioptions-=r
set guioptions-=b
set guioptions-=T
"Paste consistency with Linux
nnoremap "+p "+gp
"Change to UTF8 encoding and Nanum font
noremap <F9> :AsUtf<CR>:AsNanum<CR>
else
"In Linux, clipboard copy and paste
vnoremap "+y y:call system("xclip -i -selection clipboard", getreg("\""))<CR>:call system("xclip -i", getreg("\""))<CR>
nnoremap "+p :call setreg("\"",system("xclip -o -selection clipboard"))<CR>p
endif
"=== Function ===
"Set file format Dos to Unix.
function Tounix ()
update
e ++ff=dos
setlocal ff=unix
endfunction
"Set file format Unix to Dos.
function Todos ()
update
e ++ff=dos
endfunction
"Set File encoding to UTF-8.
function Toutf ()
update
set fileencoding=utf-8
endfunction
"Set current encoding to UTF-8.
function Asutf ()
update
set encoding=utf-8
endfunction
"Change GUI font to NanumGothic for Hangul.
function Asnanum ()
update
set guifont=NanumGothicCoding:h12
endfunction
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment