Skip to content

Commit d6effdc

Browse files
committed
update bashrc, add file line number jump support
1 parent 9eeccdf commit d6effdc

File tree

5 files changed

+54
-25
lines changed

5 files changed

+54
-25
lines changed

root/.vimrc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,10 @@ command! -nargs=1 CExprsys call CExprSystem(<q-args>)
249249

250250
""""""""""""""""""""""""""""""""""""""""""""""""""""""
251251

252+
" Example:
253+
" :e+22 ~/.vimrc
254+
command! -nargs=0 VimExeLine exe getline(".")
255+
252256
" https://www.zhihu.com/question/30782510/answer/70078216
253257
nnoremap zp :setlocal foldexpr=(getline(v:lnum)=~@/)?0:(getline(v:lnum-1)=~@/)\\|\\|(getline(v:lnum+1)=~@/)?1:2 foldmethod=expr foldlevel=0 foldcolumn=2<CR>:set foldmethod=manual<CR><CR>
254258
" unfold all: zR
@@ -276,7 +280,10 @@ let s:tags_use_gtags = 0
276280
if has("cscope") && s:tags_use_cscope
277281

278282
""""""""""""" Standard cscope/vim boilerplate
279-
283+
284+
" reset cscope:
285+
" :cs reset
286+
280287
" use both cscope and ctag for 'ctrl-]', ':ta', and 'vim -t'
281288
set cscopetag
282289

root/bashrc

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,44 @@ alias start='cmd.exe /C start ""'
77

88
alias vimt='vim --servername TEX'
99

10-
source ~/vimrc/root/rfv.sh
10+
# sudo apt install bat
11+
# alias "bat=batcat" in Ubuntu
12+
13+
# https://github.com/junegunn/fzf/blob/master/ADVANCED.md#using-fzf-as-interactive-ripgrep-launcher
14+
rfv() {
15+
# 1. Search for text in files using Ripgrep
16+
# 2. Interactively restart Ripgrep with reload action
17+
# 3. Open the file in Vim
18+
RG_PREFIX="rg --column --line-number --no-heading --color=always --smart-case "
19+
INITIAL_QUERY="${*:-}"
20+
IFS=: read -ra selected < <(
21+
FZF_DEFAULT_COMMAND="$RG_PREFIX $(printf %q "$INITIAL_QUERY")" \
22+
fzf --ansi \
23+
--disabled --query "$INITIAL_QUERY" \
24+
--bind "change:reload:sleep 0.1; $RG_PREFIX {q} || true" \
25+
--delimiter : \
26+
--preview 'batcat --color=always {1} --highlight-line {2}' \
27+
--preview-window 'up,60%,border-bottom,+{2}+3/3,~3'
28+
)
29+
[ -n "${selected[0]}" ] && vim "${selected[0]}" "+${selected[1]}"
30+
}
31+
32+
rff() {
33+
# search file contains <file path>:<line number>:
34+
# which can be generated by
35+
# 1) rg --vimgrep
36+
# 2) :YankPathLine
37+
# type `gF` in vim can jump to the line
38+
IFS=: read -ra selected < <(
39+
FZF_DEFAULT_COMMAND="rg --no-line-number -e ^.+:.+: $1" \
40+
fzf --ansi \
41+
--disabled --query "$INITIAL_QUERY" \
42+
--bind "change:reload:sleep 0.1; $RG_PREFIX {q} || true" \
43+
--delimiter : \
44+
--preview 'batcat --color=always {1} --highlight-line {2}' \
45+
--preview-window 'up,60%,border-bottom,+{2}+3/3,~3'
46+
)
47+
[ -n "${selected[0]}" ] && vim "${selected[0]}" "+${selected[1]}"
48+
}
1149

1250
. ~/vimrc/root/z.sh

root/rfv.sh

Lines changed: 0 additions & 23 deletions
This file was deleted.

root/vimrc.d/asynctasks.vim

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ let g:asyncrun_open = 6 " open quickfix window automatically at 6 lines height a
55
let g:asyncrun_rootmarks = ['.git', '.root']
66
let g:asynctasks_term_pos = 'tab'
77
let g:asynctasks_term_reuse = 1
8+
9+
" See rff() in bashrc
10+
command! -nargs=0 YankPathLine let @" = expand('%:p')[len(asyncrun#get_root('%')) + 1:] . ':' . line(".")

root/vimrc.d/plugin.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ map T <Plug>Sneak_T
2323
Plug 'markonm/traces.vim'
2424
Plug 'tomasiser/vim-code-dark'
2525

26+
Plug 'voldikss/vim-floaterm'
27+
let g:floaterm_width = 0.8
28+
let g:floaterm_height = 0.8
29+
2630
" Plug 'MattesGroeger/vim-bookmarks'
2731

2832
" Plug 'ojroques/vim-oscyank', {'branch': 'main'}

0 commit comments

Comments
 (0)