~gpanders/dotfiles

ref: c8e63bac959db19c138dcc3198a56514f0b444ff dotfiles/.vim/autoload/bracket.vim -rw-r--r-- 642 bytes
c8e63bacGreg Anders Manage dotfiles directly in home directory 1 year, 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function! s:bracket(bracket, ch)
  if a:ch ==? 'a'
    let p = ''
  elseif a:ch ==? 'b'
    let p = 'b'
  elseif a:ch ==? 'l'
    let p = 'l'
  elseif a:ch ==? 't'
    let p = 't'
  elseif a:ch ==? 'q'
    let p = 'c'
  else
    return
  endif

  let next = a:bracket ==# '[' ? 0 : 1
  let caps = toupper(a:ch) ==# a:ch
  let cnt = caps || !v:count ? '' : v:count
  let action = (caps ? (next ? 'last' : 'first') : (next ? 'next' : 'prev'))
  return ":\<C-U>" . cnt . p . action . "\<CR>"
endfunction

function! bracket#left(ch)
  return s:bracket('[', a:ch)
endfunction

function! bracket#right(ch)
  return s:bracket(']', a:ch)
endfunction