From 90eb8b887074c953315ebaad1a99b00ca36af4c6 Mon Sep 17 00:00:00 2001 From: tdro Date: Wed, 26 Aug 2020 05:35:22 -0400 Subject: .vimrc: Add jump to line and column function --- .vimrc | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to '.vimrc') diff --git a/.vimrc b/.vimrc index 0fa7a4c..a54b526 100644 --- a/.vimrc +++ b/.vimrc @@ -160,6 +160,12 @@ nmap dm :execute ':term ++close fzf-man ' . expand('') nmap di :execute ':term ++close fzf-doc ' . expand('') nmap dt :execute ':term dict -h localhost -d dict-moby-thesaurus-latest ' . expand('') +" View function documentation +nmap dp :call fzf#run({'options': ['--preview', 'echo doc {} \| psysh \| fold -s -w 80'], 'source': "psysh-doc", 'sink': ':term psysh-doc', 'down': '50%'}) + +" Jump to line +nmap jl :norm yaW \| :Jump + " Load and save sessions nmap sl :source ~/.vim/sessions/session.vim \| :source ~/.vimrc nmap ss :silent! exec "!~/.vim/hooks/pre-session-save && notify-send 'Vim session saved.'" \| :mksession! ~/.vim/sessions/session.vim \| :redraw! @@ -209,9 +215,6 @@ nmap of :call fzf#run({'options': [], 'source': "cat $FZF_FILE_MARKS", ' nmap od :call fzf#run({'options': ['--preview', 'ls {}'], 'source': "cut -d' ' -f3 $FZF_DIRECTORY_MARKS", 'sink': 'cd', 'down': '20%'}):pwd nmap oo :call fzf#run({'options': ['--preview', 'highlight -O ansi --force {}'], 'source': 'rg --files --hidden \|\| find . -type f -printf "%P\n"', 'sink': 'e', 'down': '20%'}) -" View function documentation -nmap vdp :call fzf#run({'options': ['--preview', 'echo doc {} \| psysh \| fold -s -w 80'], 'source': "psysh-doc", 'sink': ':term psysh-doc', 'down': '50%'}) - " Mappings for nnn nmap nm :NnnPicker nmap nn :NnnPicker '%:p:h' @@ -252,7 +255,10 @@ let g:nnn#set_default_mappings = 0 " Disable default mappings let g:nnn#layout = 'new' " Opens the nnn window in a split let g:nnn#layout = { 'left': '~20%' } " Left 20% of the window -" send commands to terminal https://vi.stackexchange.com/questions/14300/vim-how-to-send-entire-line-to-a-buffer-of-type-terminal + +"-------------------Scripts-------------------" + +" https://vi.stackexchange.com/questions/14300/vim-how-to-send-entire-line-to-a-buffer-of-type-terminal function s:repl(start, end, language) let g:terminal_buffer = get(g:, 'terminal_buffer', -1) if g:terminal_buffer == -1 || !bufexists(g:terminal_buffer) @@ -267,6 +273,15 @@ function s:repl(start, end, language) call term_sendkeys(g:terminal_buffer, join(getline(a:start, a:end), "\") . "\") endfunction +" jump to line and column in the format 123:13 +function s:cursor(selection) + wincmd p + let g:cursor_request = split(a:selection, ":") + call cursor(g:cursor_request[0], g:cursor_request[1]) +endfunction + +command! -nargs=? -range Jump call s:cursor(@*) + command! -nargs=? -range REPL call s:repl(, , ) -- cgit v1.2.3