Last active
February 18, 2022 18:36
-
-
Save alexDtorres/6dd155ce5381ebf0d5e4f811e9e11fb9 to your computer and use it in GitHub Desktop.
.vimrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" 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 ruler "Turn on the ruler | |
set number "Show line numbers | |
set cursorline "underline the current line in the file | |
set cursorcolumn "highlight the current column. Visible in GUI mode only. | |
set colorcolumn=80 | |
set background=dark "make vim use colors that look good on a dark background | |
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 "ignore case when searching | |
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 up the backup directories to a central place. | |
" set backupdir=$HOME/.vim/backup// | |
" set directory=$HOME/.vim/backup// | |
" ----------- Visual Configuration ---------------------------------- | |
" colorscheme mycontrast | |
set statusline=%F%m%r%h%w[%L][%{&ff}]%y[%p%%][%04l,%04v] | |
" | | | | | | | | | | | | |
" | | | | | | | | | | + 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 a bar-shaped cursor for insert mode, even through tmux. | |
if exists('$TMUX') | |
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\" | |
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\" | |
else | |
let &t_SI = "\<Esc>]50;CursorShape=1\x7" | |
let &t_EI = "\<Esc>]50;CursorShape=0\x7" | |
endif | |
" ----------- Shortcut Key Configuration ---------------------------------- | |
let mapleader = "," "remap leader to ',' which is much easier than '\' | |
"Switch to previous file with ',,' | |
nmap <leader><leader> <C-^> | |
" Open Taglist with [,s] | |
map <Leader>s :TlistToggle<CR> | |
" Use leader x to remove the current line but not erase buffer | |
map <Leader>x "_dd | |
" Exit insert mode with ii | |
imap ii <Esc> | |
" reload current file | |
map <Leader>r :so %<CR> | |
" Exit insert mode and save with jj | |
imap jj <Esc>:w<CR> | |
"CTags | |
map <Leader>ct :!ctags -R --exclude=.git --exclude=log --exclude=.svn --verbose=yes * <CR> | |
" 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("$") | |
" Supports pasting in from the clipboard | |
set pastetoggle=<F2> | |
" Navigate tabs | |
map <F3> :tabp<CR> | |
map <F4> :tabn<CR> | |
" Turn text search highlight on/off with F5 key | |
map <F5> :set hls!<bar>set hls?<CR> | |
" double percentage sign in command mode is expanded | |
" to directory of current file - http://vimcasts.org/e/14 | |
cnoremap %% <C-R>=expand('%:h').'/'<cr> | |
" insert blank line above in Normal mode | |
nnoremap <Leader>O mzO<esc>`z | |
" insert blank line below in Normal mode | |
nnoremap <Leader>o mzo<esc>`z | |
" Sort CSS properties alphabetically | |
nnoremap <leader>css :g#\({\n\)\@<=#.,/}/sort<cr> | |
" -- Number toggling | |
function! NumberToggle() | |
if(&relativenumber == 1) | |
set number | |
else | |
set relativenumber | |
endif | |
endfunc | |
nnoremap <F6> :call NumberToggle()<cr> | |
" Spell check toggle | |
map <leader>sp :setlocal spell! spelllang=en_us<CR> | |
" ----------- Plugin Configuration ---------------------------------- | |
" ---- NERDTree configuration | |
" Open NERDTree with [,d] | |
map <Leader>d :NERDTreeToggle<CR> | |
let NERDTreeShowLineNumbers=1 | |
let NERDTreeMinimalUI=1 | |
let g:nerdtree_tabs_focus_on_files=1 | |
let g:nerdtree_tabs_open_on_console_startup=1 | |
" ---- CTRL-P configuration | |
" Open fuzzy finder with leader,f | |
map <Leader>f :CtrlP<CR> | |
" Exclude files from ctrl-p finder | |
let g:ctrlp_custom_ignore = '\.git$\|\.hg$\|\.svn$' | |
" ---- ack | |
" Open ack and ackg | |
map <Leader>A :AckG | |
map <Leader>a :Ack | |
" ---- vimux configs | |
let VimuxHeight = "33" "this is percentage | |
" Inspect runner pane | |
map <Leader>vi :InspectVimTmuxRunner<CR> | |
" Close vim tmux runner opened by RunVimTmuxCommand | |
map <Leader>vq :CloseVimTmuxRunner<CR> | |
" If text is selected, save it in the v buffer and send that buffer it to tmux | |
vmap <Leader>vs "vy :call RunVimTmuxCommand(@v . "\n", 0)<CR> | |
" Select current paragraph and send it to tmux | |
nmap <Leader>vs vip<LocalLeader>vs<CR> | |
" ---- Syntax inspector via vimvasts | |
" Show syntax highlighting groups for word under cursor with CtrlShiftR | |
nmap <C-S-R> :call <SID>SynStack()<CR> | |
function! <SID>SynStack() | |
if !exists("*synstack") | |
return | |
endif | |
echo map(synstack(line('.'), col('.')), 'synIDattr(v:val, "name")') | |
endfunc | |
" ----------- Dispatch configs --------------------------------------- | |
autocmd FileType java let b:dispatch = 'javac %' | |
autocmd FileType coffee let b:dispatch = 'coffee -c %' | |
nnoremap <F9> :Dispatch<CR> | |
autocmd FileType ruby nmap <Leader>g :!ruby %<cr> | |
autocmd FileType go nmap <Leader>g :!go run %<cr> | |
autocmd FileType html nmap <Leader>g :!open %<cr> | |
autocmd FileType js nmap <Leader>g :!node %<cr> | |
" ----------- Private Configuration ---------------------------------- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment