Vim Functions

来源:互联网 发布:金山数据恢复乱码 编辑:程序博客网 时间:2024/06/05 20:29
"===================================================================="For get_last_day  :function Own_Get_Last_Day(year,month)  :  let l:l_month_day = [ [ '01' , '31' ] , [ '02' , '28' ] , [ '03' , '31' ] ,                         \ [ '04' , '30' ] , [ '05' , '31' ] , [ '06' , '30' ] ,                         \ [ '07' , '31' ] , [ '08' , '31' ] , [ '09' , '30' ] ,                         \ [ '10' , '31' ] , [ '11' , '30' ] , [ '12' , '31' ] ]  :  let l:year = a:year  :  let l:month = a:month  :  if (!(l:year%4)&&(l:year%100)) || !(l:year%400)  :    let l:l_month_day[1][1] = '29'  :  endif  :  let l:i_loop = 0  :  while l:i_loop < 12  :    if month == l:l_month_day[l:i_loop][0]  :       return l:l_month_day[l:i_loop][1]  :    endif  :    let l:i_loop = l:i_loop + 1  :  endwhile  :endfunction"===================================================================="For get_exactlly_Month  :function Own_Get_Exactlly_Month(year,month,duration)  :  let l:duration = a:duration  :  let l:year     = a:year  :  let l:month    = a:month  :  let l:left     = str2nr(l:month) + l:duration  :  if l:left <= 12 && l:left >= 1  :    let l:month = l:left  :  elseif l:left > 12  :    let l:year = l:year + l:left / 12  :    let l:month = l:left % 12  :  else  :    let l:year = l:year + l:left / 12 - 1  :    let l:month = l:left % 12 + 12  :  endif  :  if strlen(l:month) == 1  :    let l:month = '0' . l:month  :  endif  :  return l:year . ',' . l:month  :endfunction "===================================================================="For Sort  :function Own_Sort()  :  let l:i_line_nu_max= line('$')  :  let l:i_loop_1 = 1  :  while l:i_loop_1 <= l:i_line_nu_max  :    let l:l_min_str = [ getline(l:i_loop_1) , l:i_loop_1]  :    let l:i_loop_2 = 1  :    while l:i_loop_2 <= l:i_line_nu_max - l:i_loop_1  :      let l:l_cur_str = [ getline(l:i_loop_2 + l:i_loop_1) , l:i_loop_2 + l:i_loop_1]  :      let l:i_flag = Own_String_Compare(l:l_min_str[0],l:l_cur_str[0])  :      if l:i_flag == 1  :        let l:l_min_str = l:l_cur_str  :      endif  :      let l:i_loop_2 = l:i_loop_2 + 1  :    endwhile           :    call Own_Transposition(l:l_min_str[1],l:i_loop_1)  :    let l:i_loop_1 = l:i_loop_1 + 1  :  endwhile  :endfunction"===================================================================="For String Compare  :function Own_String_Compare(str_1,str_2)  :  let l:l_str_1 = a:str_1  :  let l:l_str_2 = a:str_2  :  let l:i_len_of_str_1 = strlen(l:l_str_1)  :  let l:i_len_of_str_2 = strlen(l:l_str_2)  :  let l:i_loop = 0  :  let l:i_flag = 0  :  while l:i_loop < (l:i_len_of_str_1 < l:i_len_of_str_2 ? l:i_len_of_str_1 : l:i_len_of_str_2)  :    if l:l_str_1[l:i_loop] < l:l_str_2[l:i_loop]  :      let l:i_flag = -1  :      break  :    elseif l:l_str_1[l:i_loop] > l:l_str_2[l:i_loop]  :      let l:i_flag = 1  :      break  :    else  :      let l:i_flag = 0  :      let l:i_loop = l:i_loop + 1  :      continue  :    endif  :  endwhile  :  if l:i_flag == 0  :    if l:i_len_of_str_1 < l:i_len_of_str_2  :      let l:i_flag = -1  :    elseif l:i_len_of_str_1 > l:i_len_of_str_2  :      let l:i_flag = 1  :    else  :      let l:i_flag = 0  :    endif  :  endif  :  return l:i_flag  :endfunction"===================================================================="For Transposition  :function Own_Transposition(no_1,no_2)  :  let l:i_no_1 = a:no_1  :  let l:i_no_2 = a:no_2  :  let l:l_str_1 = getline(l:i_no_1)  :  let l:l_str_2 = getline(l:i_no_2)  :  silent exe l:i_no_1 . 's /.*/'. l:l_str_2 .'/g'  :  silent exe l:i_no_2 . 's /.*/'. l:l_str_1 .'/g'  :endfunction


	
				
		
原创粉丝点击