mirror of
https://github.com/vbrandl/dotfiles
synced 2025-07-03 01:34:32 +02:00
Initial commit. Adding vim configuration
This commit is contained in:
61
editors/vim/autoload/functions.vim
Normal file
61
editors/vim/autoload/functions.vim
Normal file
@ -0,0 +1,61 @@
|
||||
" Window movement shortcuts
|
||||
" move to the window in the direction shown, or create a new window
|
||||
function! functions#WinMove(key)
|
||||
let t:curwin = winnr()
|
||||
exec "wincmd ".a:key
|
||||
if (t:curwin == winnr())
|
||||
if (match(a:key,'[jk]'))
|
||||
wincmd v
|
||||
else
|
||||
wincmd s
|
||||
endif
|
||||
exec "wincmd ".a:key
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" smart tab completion
|
||||
function! functions#Smart_TabComplete()
|
||||
let line = getline('.') " current line
|
||||
|
||||
let substr = strpart(line, -1, col('.')+1) " from the start of the current
|
||||
" line to one character right
|
||||
" of the cursor
|
||||
let substr = matchstr(substr, '[^ \t]*$') " word till cursor
|
||||
if (strlen(substr)==0) " nothing to match on empty string
|
||||
return '\<tab>'
|
||||
endif
|
||||
let has_period = match(substr, '\.') != -1 " position of period, if any
|
||||
let has_slash = match(substr, '\/') != -1 " position of slash, if any
|
||||
if (!has_period && !has_slash)
|
||||
return '\<C-X>\<C-P>' " existing text matching
|
||||
elseif ( has_slash )
|
||||
return '\<C-X>\<C-F>' " file matching
|
||||
else
|
||||
return '\<C-X>\<C-O>' " plugin matching
|
||||
endif
|
||||
endfunction
|
||||
|
||||
" execute a custom command
|
||||
function! functions#RunCustomCommand()
|
||||
up
|
||||
if g:silent_custom_command
|
||||
execute 'silent !' . s:customcommand
|
||||
else
|
||||
execute '!' . s:customcommand
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! functions#SetCustomCommand()
|
||||
let s:customcommand = input('Enter Custom Command$ ')
|
||||
endfunction
|
||||
|
||||
function! functions#TrimWhiteSpace()
|
||||
%s/\s\+$//e
|
||||
endfunction
|
||||
|
||||
function! functions#HtmlUnEscape()
|
||||
silent s/</</eg
|
||||
silent s/>/>/eg
|
||||
silent s/&/\&/eg
|
||||
endfunction
|
||||
|
Reference in New Issue
Block a user