|
" Cross-platform Vim Configuration goes in this file |
|
" |
|
" Contents |
|
" Main configuration |
|
" Visual Configuration |
|
" Shortcut Key Configuration |
|
" Plugin Configuration |
|
" Private Configuration |
|
|
|
" ----------- Main Configuration ---------------------------------- |
|
|
|
set nocompatible "don't need to keep compatibility with Vi |
|
filetype plugin indent on "enable detection, plugins and indenting in one step |
|
syntax on "Turn on syntax highlighting |
|
set encoding=utf-8 "Force UTF-8 encoding for special characters |
|
set ruler "Turn on the ruler |
|
set number "Show line numbers |
|
set numberwidth=5 |
|
|
|
if has('win32') || has ('win64') |
|
hi CursorLine ctermbg=1 guibg=#005366 |
|
hi CursorColumn ctermbg=1 guibg=#005366 |
|
endif |
|
set cursorline "underline the current line in the file |
|
set colorcolumn=80 |
|
|
|
set hidden " allow unsaved background buffers and remember marks/undo for them |
|
set history=10000 " remember more commands and search history |
|
|
|
set showcmd "show incomplete cmds down the bottom |
|
set showmode "show current mode down the bottom |
|
set foldenable "enable folding |
|
set showmatch "set show matching parenthesis |
|
set noexrc "don't use the local config |
|
"set virtualedit=all "allow the cursor to go in to "invalid" places |
|
|
|
set incsearch "find the next match as we type the search |
|
set hlsearch "hilight searches by default |
|
set ignorecase smartcase "make searches case-sensitive only if they contain upper-case characters |
|
hi Search guibg=LightBlue ctermbg=LightBlue |
|
nnoremap <cr> :nohlsearch<cr> |
|
|
|
set shiftwidth=2 "number of spaces to use in each autoindent step |
|
set tabstop=2 "two tab spaces |
|
set softtabstop=2 "number of spaces to skip or insert when <BS>ing or <Tab>ing |
|
set expandtab "spaces instead of tabs for better cross-editor compatibility |
|
set smarttab "use shiftwidth and softtabstop to insert or delete (on <BS>) blanks |
|
set shiftround "when at 3 spaces, and I hit > ... go to 4, not 5 |
|
set nowrap "no wrapping |
|
|
|
set backspace=indent,eol,start "allow backspacing over everything in insert mode |
|
set cindent "recommended seting for automatic C-style indentation |
|
set autoindent "automatic indentation in non-C files |
|
set copyindent "copy the previous indentation on autoindenting |
|
|
|
set noerrorbells "don't make noise |
|
set wildmenu "make tab completion act more like bash |
|
set wildmode=list:longest "tab complete to longest common string, like bash |
|
|
|
"set mouse-=a "disable mouse automatically entering visual mode |
|
set mouse=a "enable mouse automatically entering visual mode |
|
set hidden "allow hiding buffers with unsaved changes |
|
set cmdheight=2 "make the command line a little taller to hide 'press enter to viem more' text |
|
|
|
set clipboard=unnamed "Use system clipboard by default |
|
|
|
set splitright "splits open on the right. |
|
set splitbelow "splits open below existing window.. |
|
|
|
" Set up the backup directories to a central place. |
|
set backupdir=$VIMHOME/backup/ |
|
set directory=$VIMHOME/backup/ |
|
|
|
" keep search pattern in center of screen |
|
nnoremap <silent> n nzz |
|
nnoremap <silent> N Nzz |
|
nnoremap <silent> * *zz |
|
nnoremap <silent> # #zz |
|
nnoremap <silent> g* g*zz |
|
|
|
" ----------- Visual Configuration ---------------------------------- |
|
set background=dark "make vim use colors that look good on a dark background |
|
|
|
set statusline=%f%m%r%h%w[%l][%{&ff}]%y[%p%%][%04l,%04v][%n] |
|
" | | | | | | | | | | | | |
|
" | | | | | | | | | | | + current |
|
" | | | | | | | | | | | buffer |
|
" | | | | | | | | | | + current |
|
" | | | | | | | | | | column |
|
" | | | | | | | | | +-- current line |
|
" | | | | | | | | +-- current % into file |
|
" | | | | | | | +-- current syntax in |
|
" | | | | | | | square brackets |
|
" | | | | | | +-- current fileformat |
|
" | | | | | +-- number of lines |
|
" | | | | +-- preview flag in square brackets |
|
" | | | +-- help flag in square brackets |
|
" | | +-- readonly flag in square brackets |
|
" | +-- rodified flag in square brackets |
|
" +-- full path to file in the buffer |
|
|
|
" Use the same symbols as TextMate for tabstops and EOLs |
|
set listchars=tab:▸\ ,eol:¬ |
|
|
|
" Highlight trailing whitespace |
|
highlight ExtraWhitespace ctermbg=red guibg=red |
|
match ExtraWhitespace /\s\+$/ |
|
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/ |
|
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/ |
|
autocmd InsertLeave * match ExtraWhitespace /\s\+$/ |
|
autocmd BufWinLeave * call clearmatches() |
|
|
|
" ----------- Shortcut Key Configuration ---------------------------------- |
|
let mapleader = "," "remap leader to ',' which is much easier than '\' |
|
|
|
" mapping to make movements operate on 1 screen line in wrap mode |
|
function! ScreenMovement(movement) |
|
if &wrap |
|
return "g" . a:movement |
|
else |
|
return a:movement |
|
endif |
|
endfunction |
|
onoremap <silent> <expr> j ScreenMovement("j") |
|
onoremap <silent> <expr> k ScreenMovement("k") |
|
onoremap <silent> <expr> 0 ScreenMovement("0") |
|
onoremap <silent> <expr> ^ ScreenMovement("^") |
|
onoremap <silent> <expr> $ ScreenMovement("$") |
|
nnoremap <silent> <expr> j ScreenMovement("j") |
|
nnoremap <silent> <expr> k ScreenMovement("k") |
|
nnoremap <silent> <expr> 0 ScreenMovement("0") |
|
nnoremap <silent> <expr> ^ ScreenMovement("^") |
|
nnoremap <silent> <expr> $ ScreenMovement("$") |
|
|
|
" Spell check toggle |
|
map <leader>sp :setlocal spell! spelllang=en_us<CR> |
|
|
|
" Use leader l to rapidly toggle `set list` |
|
nmap <leader>l :set list!<CR> |
|
|
|
" reload configuration file |
|
map <Leader>r :so $MYVIMRC<CR> |
|
|
|
nmap <C-h> :bp<cr> " Ctrl-h goes to previous buffer |
|
nmap <C-l> :bn<cr> " Ctrl-l goes to next buffer |
|
|
|
nmap <C-s> :w<cr> " Ctrl-s saves |
|
imap <C-s> <esc>:w<cr>i |
|
|
|
" ARROW KEYS ARE UNACCEPTABLE - vim hard mode! |
|
map <Left> <Nop> |
|
map <Right> <Nop> |
|
map <Up> <Nop> |
|
map <Down> <Nop> |
|
|
|
" ----------- Launch configs --------------------------------------- |
|
autocmd FileType ruby nmap <Leader>g :!ruby "%"<cr> |
|
autocmd FileType java nmap <Leader>g :!javac "%"<cr> |
|
|
|
if has('win32') || has ('win64') |
|
autocmd FileType html nmap <Leader>g :silent ! start chrome "%"<cr> |
|
elseif has('mac') |
|
autocmd FileType html nmap <Leader>g :!open "%"<cr> |
|
endif |
|
|
|
autocmd FileType js nmap <Leader>g :!node "%"<cr> |
|
autocmd FileType sh nmap <Leader>g :!sh "%"<cr> |
|
|
|
" ----------- Autocommand --------------- |
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
|
" CUSTOM AUTOCMDS |
|
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" |
|
augroup vimrcEx |
|
" Clear all autocmds in the group |
|
autocmd! |
|
" Jump to last cursor position unless it's invalid or in an event handler |
|
autocmd BufReadPost * |
|
\ if line("'\"") > 0 && line("'\"") <= line("$") | |
|
\ exe "normal g`\"" | |
|
\ endif |
|
augroup END |
|
|
|
" ----------- Plugin Configuration ---------------------------------- |
|
let g:jsx_ext_required = 0 " Allow JSX in normal JS files |
|
|
|
let g:syntastic_javascript_checkers = ['eslint'] |
|
|
|
" ----------- Private Configuration ---------------------------------- |