diff --git a/vim/.vimrc b/vim/.vimrc index 43695ff..2089c81 100644 --- a/vim/.vimrc +++ b/vim/.vimrc @@ -19,9 +19,10 @@ set fileencoding=utf-8 set history=1000 " Remap the to , -" nnoremap -let mapleader="," -let maplocalleader = "," +nnoremap +" let mapleader=',' +" let maplocalleader = ',' +let mapleader=' ' " Includes ftplugin.vim which is responsible for filetype detection filetype plugin indent on @@ -485,6 +486,9 @@ set mousehide " conceal mostly for markdown set conceallevel=2 +" Highlight VCS conflict markers +match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$' + set statusline= set statusline+=%#PmenuSel# set statusline+=%{StatuslineGit()} @@ -579,16 +583,12 @@ endif " Automatically inserts one extra level of indentation in some cases set smartindent - " Affects how key presses are interpreted depending on where the cursor is set smarttab - " Tab counts as 2 columns set tabstop=2 - " Numbers of spaces to (auto)indent set shiftwidth=2 - " Spaces set expandtab @@ -597,143 +597,77 @@ set expandtab " ======================================================== " -> Hotkeys & Bindings " ======================================================== -" Remap ; to : + nnoremap ; : -" Close buffer by Q nnoremap Q :q! -" Move between splits nnoremap h nnoremap j nnoremap k nnoremap l -" Bash like keys for the vim command line cnoremap cnoremap -" , -> clears search highlight -nmap :nohlsearch -" ,, -> toggle between last open buffers -nmap -" CtrlP -> fzf :Files -nnoremap (expand('%') =~ 'NERD_tree' ? "\\" : '').":Files\" -" ,w -> strip trailing whitespace -nmap w :call StripTrailingWhitespace() -" ,x rubocop --auto-correct -nmap x :ALEFix -" ,n -> NERDTree -nmap n :NERDTreeToggle -" ,c -> next conflict marker -nmap c /\v^[<=>]{7}( .*\|$) -" ,b -> Gblame -nmap b :Gblame -" ,t -> opens new tab -nmap t :tabnew -" ,f -> prompts for search -nmap f :CtrlSF -" ,g -> Gitv -nmap g :Gitv -" ,d -> binding fucking pry -nmap d orequire 'pry'; binding.pry -nmap D Orequire 'pry'; binding.pry -" ,p -> current buffer file path -nmap p :echo @% -" ,s -> reload vimrc -nmap s :so ~/.vimrc -" ,rh -> hashrocket to : -nmap rh :%s/\v:(\w+) \=\>/\1:/g -" ,r -> -nmap r :TestFile -" ,j -> -nmap j :%!python -m json.tool +nnoremap ,, -" Switching between tabs -nmap :tabnext -nmap :tabprevious +nnoremap f (expand('%') =~ 'NERD_tree' ? "\\" : '').":Files\" +nnoremap b (expand('%') =~ 'NERD_tree' ? "\\" : '').":Buffers\" +nnoremap s (expand('%') =~ 'NERD_tree' ? "\\" : '').":Snippets\" -" n/N centers screen on the entry -nmap N Nzz -nmap n nzz +nnoremap x :ALEFix +nnoremap n :NERDTreeToggle +nnoremap c /\v^[<=>]{7}( .*\|$) +nnoremap t :tabnew +nnoremap d orequire 'pry'; binding.pry +nnoremap D Orequire 'pry'; binding.pry +nnoremap r :TestFile +nnoremap j :%!python -m json.tool +nnoremap w :w +nnoremap :nohlsearch -" Move properly when line wrapping is on +nnoremap ga :Gwrite +nnoremap gc :Gcommit +nnoremap gp :Gpush +nnoremap gup :Gpull +nnoremap gs :Gstatus +nnoremap gd :Gvdiff +nnoremap gl (expand('%') =~ 'NERD_tree' ? "\\" : '').":Commits\" + +nnoremap p :echo @% + +nnoremap :tabnext +nnoremap :tabprevious + +nnoremap yy Y +nnoremap Y y$ +nnoremap N Nzz +nnoremap n nzz nnoremap j gj nnoremap k gk +nnoremap H ^ +nnoremap L $ +nnoremap J mzJ`z +nnoremap gQ -" Visual mode indentations +vnoremap . :normal . +vnoremap J :m '>+1gv=gv +vnoremap K :m '<-2gv=gv vnoremap < >gv -" Make Y/yy consistent with D/dd and C/cc -nnoremap yy Y -nnoremap Y y$ +xmap \ Commentary +nmap \ Commentary +nmap \\ CommentaryLine -" vv/ss for splits -nnoremap vv v -" nnoremap ss s - -" Highlight VCS conflict markers -match ErrorMsg '^\(<\|=\|>\)\{7\}\([^=].\+\)\?$' - -" Start interactive EasyAlign in visual mode -vmap (EasyAlign) - -" Ctrl + e for emmet -imap , - -" Allow the . to execute once for each line of a visual selection -vnoremap . :normal . - -" Makes more sense -nnoremap H ^ -nnoremap L $ - -" Avoid entering Ex mode by pressing gQ -nnoremap gQ - -" Scratchpad nnoremap :tabnew ~/iCloud/Wiki/index.md -" I don't use it -nnoremap K -" K reverse of J -" nnoremap K fr +nnoremap vv v +" nnoremap ss s TODO: -" Move visual block -vnoremap J :m '>+1gv=gv -vnoremap K :m '<-2gv=gv - -" Keep the cursor in place while joining lines -nnoremap J mzJ`z - -" Keep old vim-commentary hotkeys -xmap \\ Commentary -nmap \\ Commentary -nmap \\\ CommentaryLine -nmap \\u CommentaryUndo - -" git -noremap ga :Gwrite -noremap gc :Gcommit -noremap gp :Gpush -noremap gup :Gpull -noremap gs :Gstatus -noremap gd :Gvdiff - -" Color under cursor -map :echo "hi<" . synIDattr(synID(line("."),col("."),1),"name") . '> trans<' . synIDattr(synID(line("."),col("."),0),"name") . "> lo<" . synIDattr(synIDtrans(synID(line("."),col("."),1)),"name") . ">" - -" EXPERIMENTAL: -noremap w :w - -nmap r :TestFile -nmap t :TestNearest -nmap t :TestNearest -nmap t :TestFile -nmap t :TestSuite -nmap t :TestLast -nmap t :TestVisit +nmap CtrlSFPrompt +nnoremap :call StripTrailingWhitespace() inoremap vnoremap @@ -741,3 +675,32 @@ cnoremap inoremap vnoremap cnoremap + +" ===================================== +" TODO: DEAL WITH THIS + +" TODO: this requires double C-b for some reason +nnoremap :Gblame + +" ,rh -> hashrocket to : TODO: think about it +" nnoremap rh :%s/\v:(\w+) \=\>/\1:/g + +" ,s -> reload vimrc TODO: do something useful instead +" nnoremap s :so ~/.vimrc +" +" nnoremap :Gitv TODO: No longer have gitv + +" Start interactive EasyAlign in visual mode +vmap (EasyAlign) +" Start interactive EasyAlign in visual mode (e.g. vipga) +xmap ga (EasyAlign) +" Start interactive EasyAlign for a motion/text object (e.g. gaip) +nmap ga (EasyAlign) + +" Ctrl + e for emmet +imap , + +" I don't use it +nnoremap K +" K reverse of J +" nnoremap K fr