123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
-
-
-
-
-
-
-
- " Purpose: Define functions better than expand("<cword>
-
-
-
-
-
-
-
- function! GetNearestKeyword()
- let c = col ('.')-1
- let ll = getline('.')
- let ll1 = strpart(ll,0,c)
- let ll1 = matchstr(ll1,'\k*$')
- let ll2 = strpart(ll,c,strlen(ll)-c+1)
- let ll2 = matchstr(ll2,'^\k*')
-
- return ll1.ll2
- endfunction
-
-
- function! GetNearestWord()
- let c = col ('.')-1
- let l = line('.')
- let ll = getline(l)
- let ll1 = strpart(ll,0,c)
- let ll1 = matchstr(ll1,'\S*$')
- let ll2 = strpart(ll,c,strlen(ll)-c+1)
- let ll2 = strpart(ll2,0,match(ll2,'$\|\s'))
- ""echo ll1.ll2
- return ll1.ll2
- endfunction
-
-
-
- function! GetCurrentWord()
- let c = col ('.')-1
- let l = line('.')
- let ll = getline(l)
- let ll1 = strpart(ll,0,c)
- let ll1 = matchstr(ll1,'\S*$')
- if strlen(ll1) == 0
- return ll1
- else
- let ll2 = strpart(ll,c,strlen(ll)-c+1)
- let ll2 = strpart(ll2,0,match(ll2,'$\|\s'))
- return ll1.ll2
- endif
- endfunction
-
-
-
- function! GetCurrentKeyword()
- let c = col ('.')-1
- let l = line('.')
- let ll = getline(l)
- let ll1 = strpart(ll,0,c)
- let ll1 = matchstr(ll1,'\k*$')
- if strlen(ll1) == 0
- return ll1
- else
- let ll2 = strpart(ll,c,strlen(ll)-c+1)
- let ll2 = matchstr(ll2,'^\k*')
-
- return ll1.ll2
- endif
- endfunction
-
-
- " use keyword definitions, skip latter spaces (see "bla word_accepted
- function! GetPreviousWord()
- let lig = getline(line('.'))
- let lig = strpart(lig,0,col('.')-1)
- return matchstr(lig, '\<\k*\>\s*$')
- endfunction
-
-
-
-
- " Pb: "if strlen(w) == " --> ") == " instead of just "==
-
- function! GetLikeCTRL_W()
- let lig = getline(line('.'))
- let lig = strpart(lig,0,col('.')-1)
-
- let s = matchstr(lig, '\s*$')
- let lig = strpart(lig, 0, strlen(lig)-strlen(s))
- " First case : last characters belong to a "word
- let w = matchstr(lig, '\<\k\+\>$')
- if strlen(w) == 0
- " otherwise, they belong to a "non word
- let w = substitute(lig, '.*\(\k\|\s\)', '', 'g')
- endif
- return w . s
- endfunction
-
-
-
|