Skip to content

Instantly share code, notes, and snippets.

@lstrgiang
Last active January 4, 2018 05:00
Show Gist options
  • Save lstrgiang/98a328cb231002604a207bb928dbb1de to your computer and use it in GitHub Desktop.
Save lstrgiang/98a328cb231002604a207bb928dbb1de to your computer and use it in GitHub Desktop.
Folded (Sectioned) Vimrc File
" Basic Configuration {{{
" Ctrl-l to toggle paste mode {{{
set pastetoggle=<C-l>
" }}}
" don't wrap lines {{{
set nowrap
" }}}
" a tab is four spaces {{{
set tabstop=4
" }}}
" allow backspacing over everything in insert mode {{{
set backspace=indent,eol,start
" }}}
" always set autoindenting on {{{
set autoindent
" }}}
" copy the previous indentation on autoindenting {{{
set copyindent
" }}}
" always show line numbers {{{
set number
" }}}
" number of spaces to use for autoindenting {{{
set shiftwidth=4
" }}}
" use multiple of shiftwidth when indenting with '<' and '>' {{{
set shiftround
" }}}
" set show matching parenthesis {{{
set showmatch
" }}}
" ignore case when searching {{{
set ignorecase
" }}}
" ignore case if search pattern is all lowercase, case-sensitive otherwise {{{
set smartcase
" }}}
" insert tabs on the start of a line according toggle {{{
set smarttab
" }}}
" highlight search terms {{{
set hlsearch
" }}}
" show search matches as you Types {{{
set incsearch
" }}}
" use softtabstop spaces instead of tab characters for indentation {{{
set expandtab
" }}}
" indent by 4 spaces when pressing <TAB> {{{
set softtabstop=4
" }}}
" automatically inserts indentation in some cases {{{
set smartindent
" }}}
" like smartindent, but stricter and more customisable {{{
set cindent
set mouse=a
" }}}
" hybrid line number {{{
set number relativenumber
" }}}
" be iMproved, required {{{
set nocompatible
" }}}
" turn of filetype {{{
filetype off
" }}}
" plugin and indentation {{{
filetype plugin indent on
" }}}
" Color the character at column 81 {{{
call matchadd('ColorColumn', '\%81v', 100)
" }}}
" Color the character at column 121 {{{
call matchadd('ColorColumn', '\%121v', 100)
" }}}
" Turn on syntax {{{
syntax on
" }}}
" No swap file allow {{{
set noswapfile
" }}}
" Set default clipboard as no clipboard {{{
set clipboard=unnamed
" }}}
" }}}
" Mapping {{{
" Leader key {{{
let mapleader = ","
" }}}
vmap Q gq
nmap Q gqap
" Basic operation {{{
map <leader>x <C-o>:x<cr>
map <leader>q <C-o>:q<cr>
map <leader>w <C-o>:w!<cr>
map <leader>aq <C-o>:q!<cr>
nmap <leader>w :w!<cr>
inoremap <leader>x <C-o>:x<cr>
inoremap <leader>q <C-o>:q<cr>
inoremap <leader>w <C-o>:w!<cr>
inoremap <leader>aq <C-o>:q!<cr>
" }}}
" Clear search highlight {{{
map <silent> <leader><cr> :noh<cr>
" }}}
" Remap : key {{{
nnoremap ; :
" }}}
" Edit vim files {{{
nmap <silent> <leader>ev :e $MYVIMRC<CR>
nmap <silent> <leader>sv :so $MYVIMRC<CR>
" }}}
" Pane navigation {{{
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" }}}
" Inden mapping {{{
map <S-.> <C-}>
" }}}
" Escape key remap {{{
imap jj <Esc>
" }}}
" Tabs operations and navigation {{{
map <C-c> :tabnew<cr>
map <C-x> :tabclose<cr>
map <C-n> gt
map <C-\> gT
map <leader>tm :tabmove
" }}}
" Map r for redo {{{
map r <C-r>
" }}}
" Opens a new tab with the current buffer's path {{{
map <leader>te :tabedit <c-r>=expand("%:p:h")<cr>/
" }}}
" }}}
" File Types Based Configuration {{{
autocmd filetype html,xml set listchars-=tab:>.
autocmd Filetype sass setlocal noexpandtab tabstop=2
" }}}
" Autocmd {{{
" Auto toggle hybrid line number {{{
augroup numbertoggle
autocmd!
autocmd BufEnter,FocusGained,InsertLeave * set relativenumber
autocmd BufLeave,FocusLost,InsertEnter * set norelativenumber
augroup END
" }}}
" Auto toggle for goyo {{{
function! s:goyo_enter()
silent !tmux set status off
silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z
set noshowmode
set noshowcmd
set scrolloff=999
set norelativenumber
set nonumber
Limelight
endfunction
function! s:goyo_leave()
silent !tmux set status on
silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z
set showmode
set showcmd
set scrolloff=5
set relativenumber
Limelight!
endfunction
autocmd! User GoyoEnter nested call <SID>goyo_enter()
autocmd! User GoyoLeave nested call <SID>goyo_leave()
" }}}
" }}}
" Plugin Mapping {{{
" Mapping NERDTree {{{
noremap <space><space> :NERDTreeToggle<cr>
" }}}
" Mapping TableMode {{{
nmap <leader>tb :TableModeToggle<cr>
" }}}
" Mapping Php Cs Fixer {{{
nnoremap <silent><leader>pcd :call PhpCsFixerFixDirectory()<CR>
nnoremap <silent><leader>pcf :call PhpCsFixerFixFile()<CR>
" }}}
" Mapping CtrlP {{{
map <leader>b :CtrlPBuffer<CR>
let g:ctrlp_map = '<leader>f'
" }}}
" Mapping Vimwiki {{{
nmap <Leader>as <Plug>VimwikiIndex
nmap <Leader>ai <Plug>VimwikiDiaryIndex
nmap <Leader>dt <Plug>VimwikiTabMakeDiaryNote
nmap <Leader>dn <Plug>VimwikiMakeDiaryNote
nmap <Leader>dy <Plug>VimwikiMakeYesterdayDiaryNote
" }}}
" Mapping Tagbar {{{
nmap <F8> :TagbarToggle<CR>
" }}}
" }}}
" Plugin Installation {{{
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
" ----- Unused plugins
"Plugin 'xolox/vim-misc'
"Plugin 'xolox/vim-notes'
"Plugin 'vim-airline/vim-airline-themes'
"Plugin 'bling/vim-airline'
"Plugin 'dhruvasagar/vim-table-mode'
"Plugin 'Quramy/tsuquyomi'
" ------ Installed plugins
Plugin 'scrooloose/nerdcommenter'
Plugin 'scrooloose/nerdtree'
Plugin 'majutsushi/tagbar'
Plugin 'jiangmiao/auto-pairs'
Plugin 'kien/ctrlp.vim'
Plugin 'nightsense/office'
Plugin 'joonty/vdebug'
Plugin 'tpope/vim-surround'
Plugin 'tpope/vim-fugitive'
Plugin 'easymotion/vim-easymotion'
Plugin 'Shougo/vimproc.vim'
Plugin 'stephpy/vim-php-cs-fixer'
Plugin 'vimwiki/vimwiki'
Plugin 'tbabej/taskwiki'
Plugin 'leafgarland/typescript-vim'
Plugin 'vim-scripts/AutoComplPop'
Plugin 'rking/ag.vim'
Plugin 'mzlogin/vim-markdown-toc'
Plugin 'JamshedVesuna/vim-markdown-preview'
Plugin 'junegunn/goyo.vim'
Plugin 'junegunn/limelight.vim'
Plugin 'nvie/vim-flake8'
Plugin 'christoomey/vim-tmux-navigator'
Plugin 'benmills/vimux'
call vundle#end() " required
"
" }}}
" Vim Colorscheme {{{
colorscheme office-dark
" }}}
" Plugin Configuration {{{
" General Configuration {{{
" Vim AG configuration {{{
let g:ag_working_path_mode="r"
" }}}
" CtrlP configuration {{{
let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']
" }}}
" Vim Markdown Preview {{{
let vim_markdown_preview_github=1
let vim_markdown_preview_hotkey='<C-m>'
" }}}
" }}}
" PHP CS Fixer Configuration {{{
let g:php_cs_fixer_level = "psr2"
let g:php_cs_fixer_config_file = '~/.php_cs'
"let g:php_cs_fixer_config = "default"
"let g:php_cs_fixer_rules = "@PSR2"
let g:php_cs_fixer_php_path = "$HOME/phpbrew/bin/php"
let g:php_cs_fixer_enable_default_mapping = 1
let g:php_cs_fixer_dry_run = 0
let g:php_cs_fixer_verbose = 0
" }}}
" Vimwiki Configuration {{{
let g:vimwiki_folding = 'expr'
let g:vimwiki_list = [{'path': '~/vimwiki/', 'path_html': '~/vimwiki/public/'}]
let g:taskwiki_use_python2="yes"
"let g:vimwiki_use_calendar='1'
let g:vimwiki_folding='syntax'
" }}}
" VDebug Configuration {{{
" Hapitas project configuration
let g:vdebug_options = {
\ 'path_maps': {"/GitHub": "/ozv"}
\}
let g:vdebug_options["port"] = 9000
let g:vdebug_options["break_on_open"] = 0
" }}}
"
" }}}
" vim: foldmethod=marker
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment