-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy_func.vim
29 lines (29 loc) · 1.09 KB
/
my_func.vim
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! Add_project_vim_dir()
let l:proj_root = expand('%:p:h')
let l:proj_runtime = l:proj_root . '/.vim'
if isdirectory(l:proj_runtime)
let &runtimepath = &runtimepath . ',' . l:proj_runtime
endif
endfunction
" 代码搬运自https://stackoverflow.com/questions/1533565/how-to-get-visually-selected-text-in-vimscript/6271254#6271254
function! WS_get_visual_selection()
" Why is this not a built-in Vim script function?!
let [line_start, column_start] = getpos("'<")[1:2]
let [line_end, column_end] = getpos("'>")[1:2]
let lines = getline(line_start, line_end)
if len(lines) == 0
return ''
endif
let lines[-1] = lines[-1][: column_end - (&selection == 'inclusive' ? 1 : 2)]
let lines[0] = lines[0][column_start - 1:]
return join(lines, "\n")
endfunction
" https://github.com/junegunn/vim-plug/issues/469#issuecomment-226965736
function! WS_unplug(repo)
let repo = substitute(a:repo, '[\/]\+$', '', '')
let name = fnamemodify(repo, ':t:s?\.git$??')
call remove(g:plugs, name)
call remove(g:plugs_order, index(g:plugs_order, name))
endfunction
" }}}