diff --git a/vim/vim.symlink/functions.vim b/vim/vim.symlink/functions.vim deleted file mode 100644 index d0d4bd3..0000000 --- a/vim/vim.symlink/functions.vim +++ /dev/null @@ -1,73 +0,0 @@ -" Window movement shortcuts -" move to the window in the direction shown, or create a new window -function! 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 - -" recursively search up from dirname, sourcing all .vimrc.local files along the way -function! ApplyLocalSettings(dirname) - " convert windows paths to unix style - let l:curDir = substitute(a:dirname, '\\', '/', 'g') - - " walk to the top of the dir tree - let l:parentDir = strpart(l:curDir, 0, strridx(l:curDir, '/')) - if isdirectory(l:parentDir) - call ApplyLocalSettings(l:parentDir) - endif - - " now walk back down the path and source .vimsettings as you find them. - " child directories can inherit from their parents - let l:settingsFile = a:dirname . '/.vimrc.local' - if filereadable(l:settingsFile) - exec ':source' . l:settingsFile - endif -endfunction - -" smart tab completion -function! 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 '\' - 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 '\\' " existing text matching - elseif ( has_slash ) - return '\\' " file matching - else - return '\\' " plugin matching - endif -endfunction - -" execute a custom command -function! RunCustomCommand() - up - if g:silent_custom_command - execute 'silent !' . s:customcommand - else - execute '!' . s:customcommand - endif -endfunction - -function! SetCustomCommand() - let s:customcommand = input('Enter Custom Command$ ') -endfunction - -function! TrimWhiteSpace() - %s/\s\+$//e -endfunction diff --git a/vim/vimrc.symlink b/vim/vimrc.symlink index 8b96038..068d12c 100644 --- a/vim/vimrc.symlink +++ b/vim/vimrc.symlink @@ -5,9 +5,6 @@ " load plugins from vundle source ~/.vim/plugins.vim -" load functions -source ~/.vim/functions.vim - " Abbreviations abbr funciton function abbr teh the @@ -244,6 +241,84 @@ map r :call RunCustomCommand() " map s :call SetCustomCommand() let g:silent_custom_command = 0 +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" => Functions +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +" Window movement shortcuts +" move to the window in the direction shown, or create a new window +function! 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 + +" recursively search up from dirname, sourcing all .vimrc.local files along the way +function! ApplyLocalSettings(dirname) + " convert windows paths to unix style + let l:curDir = substitute(a:dirname, '\\', '/', 'g') + + " walk to the top of the dir tree + let l:parentDir = strpart(l:curDir, 0, strridx(l:curDir, '/')) + if isdirectory(l:parentDir) + call ApplyLocalSettings(l:parentDir) + endif + + " now walk back down the path and source .vimsettings as you find them. + " child directories can inherit from their parents + let l:settingsFile = a:dirname . '/.vimrc.local' + if filereadable(l:settingsFile) + exec ':source' . l:settingsFile + endif +endfunction + +" smart tab completion +function! 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 '\' + 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 '\\' " existing text matching + elseif ( has_slash ) + return '\\' " file matching + else + return '\\' " plugin matching + endif +endfunction + +" execute a custom command +function! RunCustomCommand() + up + if g:silent_custom_command + execute 'silent !' . s:customcommand + else + execute '!' . s:customcommand + endif +endfunction + +function! SetCustomCommand() + let s:customcommand = input('Enter Custom Command$ ') +endfunction + +function! TrimWhiteSpace() + %s/\s\+$//e +endfunction + """"""""""""""""""""""""""""""""""""""""""""""""""""""""""" " => Plugins """""""""""""""""""""""""""""""""""""""""""""""""""""""""""