From f542d8987fe3aedbcc0e0bd1b7c631bcc941f9fb Mon Sep 17 00:00:00 2001 From: DarkWiiPlayer Date: Thu, 26 Oct 2017 11:10:43 +0200 Subject: [PATCH] Lots of Improvements! :) Moved some navigation-related stuff together. Added `Matchinglines(pattern)` function that returns a list of lines where `pattern` is found in a format understood by `lex` and `cex` commands. Added three new ruby commands that find method, class and module definitions in a file and ad them to the location list. --- vimrc | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/vimrc b/vimrc index 00996a0..25ec1e5 100644 --- a/vimrc +++ b/vimrc @@ -98,6 +98,15 @@ noremap :hide noremap :bdelete nnoremap :bnext nnoremap :bprevious +nnoremap n :lnext +nnoremap p :lNext +nnoremap cn :cnext +nnoremap cp :cNext +nnoremap Bi i +nnoremap Ea a +" This one does nothing, but I'm adding it to remember not to remap the tab key +nnoremap +nnoremap noremap :setl number! noremap :setl relativenumber! noremap :setl autowriteall!:setl autowriteall? @@ -110,12 +119,9 @@ nnoremap t :Removetrailingspaces nnoremap :copy . nnoremap dx 0"_d$ nnoremap dcx 0d$ -nnoremap Bi i -nnoremap Ea a nnoremap : :let @* = @: " Tabs vs. Spaces -nnoremap :retab! nnoremap :setl expandtab!:set expandtab? " todo: custom function to retab only indentation @@ -152,6 +158,14 @@ digraph oe 246 digraph OE 214 digraph ss 223 +" === GENERAL UTILITIES === +function! Matchinglines(pattern) + let list = [] + let pattern = a:pattern + exec "g/".pattern."/ call add(list, expand('%').'('.line('.').') : '.matchstr(getline('.'), '".pattern."'))" + return list +endfunc + " === GENERAL AUTOCOMMANDS === nnoremap h :call toggleWUC() @@ -238,6 +252,7 @@ function! AddWinMinHeight(num) endfunc nnoremap = :call AddWinMinHeight(1) nnoremap - :call AddWinMinHeight(-1) +nnoremap 0 :Equal if has("autocmd") @@ -284,6 +299,9 @@ au BufNewFile,BufRead *.c,*.cpp,*.h,*.hpp :nnoremap ; m'$a;`' " --- Ruby Stuff --- " Insert Stuff +au BufNewFile,BufRead *.rb :command! -buffer Defines lex Matchinglines("^\\s\\+def\\>") +au BufNewFile,BufRead *.rb :command! -buffer Classes lex Matchinglines("^\\s\\+class\\>") +au BufNewFile,BufRead *.rb :command! -buffer Modules lex Matchinglines("^\\s\\+module\\>") au BufNewFile,BufRead *.rb :nnoremap ic oclass m'end`'a au BufNewFile,BufRead *.rb :nnoremap id odef m'()end`'a " Other Stuff