Skip to content

Instantly share code, notes, and snippets.

@shingo-mori
Last active July 17, 2018 15:05
Show Gist options
  • Save shingo-mori/16de7589f3e1cf86a8093371044b895a to your computer and use it in GitHub Desktop.
Save shingo-mori/16de7589f3e1cf86a8093371044b895a to your computer and use it in GitHub Desktop.
my vim settings
" ----------------------------------------------------------------------------
" KEY MAPS
" ----------------------------------------------------------------------------
let mapleader = ","
let maplocalleader = ","
" Useful macros
nnoremap \a :set formatoptions+=a<CR>:echo "autowrap enabled"<CR>
nnoremap \A :set formatoptions-=a<CR>:echo "autowrap disabled"<CR>
nnoremap \g :GitGutterToggle<CR>
" execute previous command inside another tmux pane
nnoremap \r :!tmux send-keys -t 0:0.1 C-p C-j <CR><CR>
" Switch linewise keys.
nmap j gj
nmap k gk
" Emacs-like bindings in the command line from `:h emacs-keys`
cnoremap <C-a> <Home>
cnoremap <C-b> <Left>
cnoremap <C-f> <Right>
cnoremap <C-d> <Del>
cnoremap <C-e> <End>
cnoremap <M-b> <S-Left>
cnoremap <M-f> <S-Right>
cnoremap <M-d> <S-right><Delete>
cnoremap <C-g> <C-c>
" Use the space key to toggle folds
nnoremap <space> za
vnoremap <space> zf
" ----------------------------------------------------------------------------
" CUSTOM COMMANDS AND FUNCTIONS
" ----------------------------------------------------------------------------
" Close all buffers except this one
command! BufCloseOthers %bd|e#
" `:e` on the current path
cnoremap %e e <C-\>eCurrentFileDir()<CR>
function! CurrentFileDir()
return "e " . expand("%:p:h") . "/"
endfunction
" Search for the word under the cursor in the current directory
nmap <M-k> mo:Ack! "\b<cword>\b" <CR>
nmap <M-S-k> mo:Ggrep! "\b<cword>\b" <CR>
" ----------------------------------------------------------------------------
" OPTIONS
" ----------------------------------------------------------------------------
set autoindent
set autoread
set autowrite
set backspace=indent,eol,start
" Allow backspace beyond insertion point
set clipboard+=unnamedplus
set copyindent
set directory-=. " Don't store temp files in cwd
set encoding=utf8
set expandtab
set fillchars=vert:\ ,stl:\ ,stlnc:\ ,
" Unicode chars for diffs/folds, and rely on
" Colors for window borders
set hidden
set hlsearch
set ignorecase
set incsearch
set infercase
set laststatus=2 " Always show status bar
set list
set lcs=trail:·,tab:>>
set nobackup
set nonumber
set nowritebackup
set ruler
set shiftround
set shiftwidth=2
set showmatch
set smartcase
set softtabstop=2
set tabstop=2
set textwidth=80
set visualbell t_vb= " No flashing or beeping at all
if has('nvim')
let g:python_host_prog = '/usr/bin/python2'
let g:python3_host_prog = '/usr/bin/python3'
endif
" ----------------------------------------------------------------------------
" PLUGIN SETTINGS
" ----------------------------------------------------------------------------
call plug#begin('~/.vim/plugged')
" ack.vim
" ag results on QuickFix window
Plug 'mileszs/ack.vim'
" Tell ack.vim to use ag (the Silver Searcher) instead
if executable('ag')
let g:ackprg = 'ag --vimgrep'
endif
nnoremap <Leader>a :Ack!<Space>
" ALE (Asynchronous Lint Engine)
Plug 'w0rp/ale'
" deoplete
" asynchronous completion framework
if has('nvim')
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
Plug 'Shougo/deoplete.nvim'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
endif
"let g:deoplete#enable_at_startup = 1
" fzf
" fuzzy finder
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
Plug 'junegunn/fzf.vim'
nnoremap ; :Buffers<CR>
nnoremap <Leader>r :Tags<CR>
nnoremap <Leader>t :Files<CR>
" gitgutter
" shows git diffs in the gutter
Plug 'airblade/vim-gitgutter'
" goyo
" distraction free writing
Plug 'junegunn/goyo.vim'
" vim-autoformat
Plug 'Chiel92/vim-autoformat'
" vim-markdown-preview
Plug 'JamshedVesuna/vim-markdown-preview'
let vim_markdown_preview_browser='Google Chrome'
let vim_markdown_preview_github=1
let vim_markdown_preview_temp_file=1
call plug#end()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment