Skip to content

Instantly share code, notes, and snippets.

@kiyor
Last active January 1, 2016 17:09
Show Gist options
  • Select an option

  • Save kiyor/8175407 to your computer and use it in GitHub Desktop.

Select an option

Save kiyor/8175407 to your computer and use it in GitHub Desktop.
vim conf
let $VIMRUNTIME='~/.vim'
filetype plugin indent on
syntax on
" load plugin, need execute before load colorscheme
execute pathogen#infect()
" header buffer, change your name in *.hd
autocmd BufNewFile *.* call CreateFile()
autocmd BufWritePre,FileWritePre *.* ks|call LastMod()|'s
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
set viminfo='10,\"100,:20,%,n~/.viminfo
if $TERM == "xterm-256color"
set t_Co=256
endif
" this two function need below 12 line
function CreateFile()
execute "read !".expand($VIMRUNTIME)."/headers/header ".expand("%")." Kiyor"
execute "1,12g/File Name :.*/s//File Name : " .expand("%")
execute "1,12g/Creation Date :.*/s//Creation Date : " .strftime("%m-%d-%Y")
execute ":22"
endfunction
function LastMod()
execute "1,12g/Last Modified :.*/s//Last Modified : " .strftime("%c")
endfunction
function SpaceReIndent()
execute "silent! %s/ /\t/g"
endfunction
" basic setup
set number
set relativenumber
set autoindent
set mouse=a
set hlsearch
set linespace=4
set shiftwidth=4
set tabstop=4
set numberwidth=4
set softtabstop=4
set wrap
set wildmode=longest,list,full
set wildmenu
set ruler
set equalalways
set matchpairs=(:),{:},[:],<:>
set whichwrap=b,s,<,>,[,]
set writebackup
set display=lastline
set foldmethod=syntax
set showmatch
set ignorecase smartcase
set incsearch
set magic
set smartindent
set backspace=indent,eol,start
set statusline=\ %<%F[%1*%M%*%n%R%H]%=\ %y\ %0(%{&fileformat}\ %{&encoding}\ %c:%l/%L%)\
" if you don't need under line
set cursorline
colorscheme jellybeans
let g:javascript_enable_domhtmlcss=1
set pastetoggle=<F2>
" for plugin tagbar
nmap <F4> :TagbarToggle<CR>
" for plugin easymotion
map <C-j> <Leader><Leader>w
" toggle folding
map <Space> zA
" tagbar setup
let g:tagbar_ctags_bin = '/usr/local/bin/ctags'
let g:tagbar_width = 30
" gotags setup
let g:tagbar_type_go = {
\ 'ctagstype' : 'go',
\ 'kinds' : [
\ 'p:package',
\ 'i:imports:1',
\ 'c:constants',
\ 'v:variables',
\ 't:types',
\ 'n:interfaces',
\ 'w:fields',
\ 'e:embedded',
\ 'm:methods',
\ 'r:constructor',
\ 'f:functions'
\ ],
\ 'sro' : '.',
\ 'kind2scope' : {
\ 't' : 'ctype',
\ 'n' : 'ntype'
\ },
\ 'scope2kind' : {
\ 'ctype' : 't',
\ 'ntype' : 'n'
\ },
\ 'ctagsbin' : 'gotags',
\ 'ctagsargs' : '-sort -silent'
\ }
" neocomplete setup plugin need lua
let g:acp_enableAtStartup = 0
let g:neocomplete#enable_at_startup = 1
let g:neocomplete#enable_smart_case = 1
let g:neocomplete#sources#syntax#min_keyword_length = 3
let g:neocomplete#lock_buffer_name_pattern = '\*ku\*'
let g:neocomplete#sources#dictionary#dictionaries = {
\ 'default' : '',
\ 'vimshell' : $HOME.'/.vimshell_hist',
\ 'scheme' : $HOME.'/.gosh_completions'
\ }
if !exists('g:neocomplete#keyword_patterns')
let g:neocomplete#keyword_patterns = {}
endif
let g:neocomplete#keyword_patterns['default'] = '\h\w*'
" neosnippet setup
" Plugin key-mappings.
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
imap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)"
\: pumvisible() ? "\<C-n>" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)"
\: "\<TAB>"
" For snippet_complete marker.
if has('conceal')
set conceallevel=2 concealcursor=i
endif
" go auto formater setup
autocmd FileType go autocmd BufWritePre <buffer> Fmt
" python replace space to tab
autocmd BufWritePre,FileWritePre *.py call SpaceReIndent()
" markdown setup
nmap <F7> :%!/usr/local/bin/Markdown.pl --html4tags <CR>
" CtrlP setup
" let g:ctrlp_user_command = 'find %s -type f'
" overwrite regular Ctrl+P to CtrlP .
" it will only buffer current directory
let g:ctrlp_cmd = 'CtrlP .'
" jellybeans colorscheme
let g:jellybeans_use_lowcolor_black = 0
" if run gui mode then setup Font and CMD+a,c,v
if has('gui_running')
set guifont=Menlo:h16
nmap <C-a> gg"+yG
vmap <C-a> gg"+yG
nmap <C-c> y:call system("pbcopy", getreg("\""))<CR>
vmap <C-c> y:call system("pbcopy", getreg("\""))<CR>
nmap <C-v> :call setreg("\"",system("pbpaste"))<CR>p
vmap <C-v> :call setreg("\"",system("pbpaste"))<CR>p
" if using terminal mode then use Ctrl instead of CMD
else
let g:solarized_termcolors=256
nmap <D-a> gg"+yG
vmap <D-a> gg"+yG
nmap <D-c> y:call system("pbcopy", getreg("\""))<CR>
vmap <D-c> y:call system("pbcopy", getreg("\""))<CR>
nmap <D-v> :call setreg("\"",system("pbpaste"))<CR>p
vmap <D-v> :call setreg("\"",system("pbpaste"))<CR>p
endif
" Set comment characters for common languages
autocmd FileType python,sh,bash,zsh,ruby,perl,muttrc let StartComment="#" | let EndComment=""
autocmd FileType html let StartComment="<!--" | let EndComment="-->"
autocmd FileType php,cpp,javascript let StartComment="//" | let EndComment=""
autocmd FileType c,css,go let StartComment="/*" | let EndComment="*/"
autocmd FileType vim let StartComment="\"" | let EndComment=""
autocmd FileType ini let StartComment=";" | let EndComment=""
autocmd FileType vim let StartComment='"' | let EndComment=""
" Toggle comments on a visual block
function! CommentLines()
" remove comment
try
execute ":s@^".g:StartComment." @\@g"
execute ":s@ ".g:EndComment."$@@g"
" add comment
catch
execute ":s@^@".g:StartComment." @g"
execute ":s@$@ ".g:EndComment."@g"
endtry
endfunction
" Comment conveniently
map <Leader>c :call CommentLines()<CR>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment