You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

110 lines
3.0 KiB

2 months ago
set foldmethod=manual
2 years ago
function! GetColumn()
let l:line = getline(line('.'))[0:col('.')]
let l:count = count(l:line,b:div) + 1
return l:count
endfunction
function! SortByColumn(...)
execute "normal! mm"
let l:column = GetColumn()
let l:column= l:column - 1
let reverse= get(a:, 1, 0)
if reverse == "!"
execute '2,$sort! /\(^\([^'.b:div.']*'.b:div.'\)\{'.l:column.'}\)\@<=[^'.b:div.']*/ r'
" execute '2,$sort! /\([^'.b:div.']*'.b:div.'\)\{'.column.'}/'
else
execute '2,$sort /\(^\([^'.b:div.']*'.b:div.'\)\{'.l:column.'}\)\@<=[^'.b:div.']*/ r'
" execute '2,$sort /\([^'.b:div.']*'.b:div.'\)\{'.column.'}/'
endif
execute "normal! `m"
endfunction
command! -nargs=0 -bang Sort :call SortByColumn("<bang>")
function! Align()
8 months ago
execute "normal! :Tabularize /" . b:div . "\<CR>"
" execute "normal! :Tabularize /" . b:div . "/l0\<CR>"
2 years ago
endfunction
command! Align :call Align()
function! UnAlign()
8 months ago
" execute "normal!
" \:%s/ \\zs \\+\\ze//g\<CR>
" \:%s/\\zs \\ze".b:div."//g\<CR>
" \:noh\<CR>"
2 years ago
execute "normal!
8 months ago
\:%s/ *" . b:div . " */".b:div."/g\<CR>
2 years ago
\:noh\<CR>"
8 months ago
2 years ago
endfunction
command! UnAlign :call UnAlign()
function! MoveColumn(col)
let l:target = a:col
let l:current = GetColumn()
if l:current < l:target
let l:target = l:target - 1
endif
if l:current != l:target
execute "normal! ggF".b:div."l\<C-v>Gf".b:div."x0"
if a:col > 1
execute "normal! f".b:div
if a:col > 2
execute "normal! " . repeat(";", a:col - 2)
endif
execute "normal! l"
endif
execute "normal! P"
endif
endfunction
command! -nargs=1 MoveColumn :call MoveColumn(<f-args>)
2 months ago
function! Filter(pattern)
execute "normal! qaqqbqgg\"add"
execute "g!/".a:pattern."/d B"
execute "normal! gg\"aPG\"bpdd"
execute ".,$fold"
execute "g/^\s*$/de"
execute "normal! gg"
endfunction
command! -nargs=1 Filter :call Filter(<f-args>)
function! DeleteColumn()
execute "normal! mm"
execute "normal! /".b:div."\\|^\\$\<CR>"
execute "normal! `mNgg\<C-V>Gnhx"
endfunction
command! -nargs=0 Delete :call DeleteColumn()
function CanApps()
execute "normal! mm"
execute "normal! /".b:div."\\|^\\$\<CR>"
execute "normal! `mNggw\<C-V>GIhttps://canapps.sanger.ac.uk/action/Cancer_Pipeline_Logs?id=\<Esc>"
endfunction
command! CanApps :call CanApps()
function UnFilter()
execute "normal! zE"
endfunction
command! UnFilter :call UnFilter()
function! SepFoldText()
return repeat("-", winwidth(0))
endfunction
setlocal foldtext=SepFoldText()
2 years ago
execute "normal! :nnoremap <buffer> <tab> /" . b:div . "<CR>l:noh<CR>\<CR>"
execute "normal! :nnoremap <buffer> <s-tab> /" . b:div . "<CR>NNl:noh<CR>\<CR>"
8 months ago
imap <buffer> <Esc> <Esc>mm:Align<CR>`m
2 years ago
nnoremap <buffer> <leader>s :Sort<CR>
nnoremap <buffer> <leader>S :Sort!<CR>
nnoremap <buffer> <leader>m1 :MoveColumn 1<CR>
nnoremap <buffer> <leader>m2 :MoveColumn 2<CR>
nnoremap <buffer> <leader>m3 :MoveColumn 3<CR>
nnoremap <buffer> <leader>m4 :MoveColumn 4<CR>
nnoremap <buffer> <leader>m5 :MoveColumn 5<CR>
nnoremap <buffer> <leader>m6 :MoveColumn 6<CR>