/bundle/exvim/autoload/exUtility.vim
Vim Script | 1314 lines | 779 code | 190 blank | 345 comment | 165 complexity | 43c469ec790a26d6d527ce778882bdd3 MD5 | raw file
- " ======================================================================================
- " File : exUtility.vim
- " Author : Wu Jie
- " Last Change : 11/30/2009 | 18:49:57 PM | Monday,November
- " Description :
- " ======================================================================================
- " check if plugin loaded
- if exists('loaded_exutility_auto') || &cp
- finish
- endif
- let loaded_exutility_auto=1
- "/////////////////////////////////////////////////////////////////////////////
- " variables
- "/////////////////////////////////////////////////////////////////////////////
- " ========================================================
- " local variable initialization
- " ========================================================
- " ------------------------------------------------------------------
- " Desc: store the highlight strings
- " ------------------------------------------------------------------
- let s:ex_hlRegMap = ["","q","w","e","r"]
- " ------------------------------------------------------------------
- " Desc: local script vairable initialization
- " ------------------------------------------------------------------
- let s:ex_editbuf_num = -1
- let s:ex_pluginbuf_num = -1
- " ------------------------------------------------------------------
- " Desc: swap buf infos
- " ------------------------------------------------------------------
- let s:ex_swap_buf_num = -1
- let s:ex_swap_buf_pos = []
- " ------------------------------------------------------------------
- " Desc: file browse
- " ------------------------------------------------------------------
- let s:ex_level_list = []
- " ------------------------------------------------------------------
- " Desc: special mark text
- " ------------------------------------------------------------------
- let s:ex_special_mark_pattern = 'todo\|xxx\|fixme'
- if exists('g:ex_todo_keyword')
- for item in split(tolower(g:ex_todo_keyword), ' ')
- let s:ex_special_mark_pattern .= '\|\<' . item . '\>'
- endfor
- endif
- if exists('g:ex_comment_lable_keyword')
- for item in split(tolower(g:ex_comment_lable_keyword), ' ')
- let s:ex_special_mark_pattern .= '\|\<' . item . '\>'
- endfor
- endif
- " ------------------------------------------------------------------
- " Desc: language file maps
- " ------------------------------------------------------------------
- let s:ex_exvim_lang_map = {}
- let s:ex_exvim_lang_map['asm'] = [ 'asm', 'ASM' ]
- let s:ex_exvim_lang_map['awk'] = [ 'awk', 'gawk', 'mawk' ]
- let s:ex_exvim_lang_map['batch'] = [ 'bat' ]
- let s:ex_exvim_lang_map['c'] = [ 'c', 'C' ]
- "changed by showgood: remove unnecessary extension type
- " let s:ex_exvim_lang_map['cpp'] = ['c++', 'cc', 'cp', 'cpp', 'cxx', 'h', 'H', 'h++', 'hh', 'hp', 'hpp', 'hxx', 'inl', 'ipp' ]
- let s:ex_exvim_lang_map['cpp'] = ['cpp', 'h', 'hpp']
- let s:ex_exvim_lang_map['c#'] = [ 'cs' ]
- let s:ex_exvim_lang_map['doxygen'] = [ 'dox', 'doxygen' ]
- let s:ex_exvim_lang_map['debug'] = [ 'log', 'err', 'exe' ]
- let s:ex_exvim_lang_map['html'] = [ 'htm', 'html' ]
- let s:ex_exvim_lang_map['ini'] = [ 'ini', 'cfg' ]
- let s:ex_exvim_lang_map['java'] = [ 'java' ]
- let s:ex_exvim_lang_map['javascript'] = [ 'js' ]
- let s:ex_exvim_lang_map['lua'] = [ 'lua' ]
- let s:ex_exvim_lang_map['make'] = [ 'mak', 'mk', 'Makefile', 'makefile' ]
- let s:ex_exvim_lang_map['matlab'] = [ 'm' ]
- " let s:ex_exvim_lang_map['python'] = [ 'py', 'pyw', 'pyx', 'pxd' ]
- let s:ex_exvim_lang_map['python'] = [ 'py']
- let s:ex_exvim_lang_map['ruby'] = [ 'rb', 'ruby' ]
- " let s:ex_exvim_lang_map['sh'] = [ 'sh', 'SH', 'bsh', 'bash', 'ksh', 'zsh' ]
- let s:ex_exvim_lang_map['sh'] = [ 'sh']
- let s:ex_exvim_lang_map['shader'] = [ 'hlsl', 'vsh', 'psh', 'fx', 'fxh', 'cg', 'shd', 'glsl' ]
- let s:ex_exvim_lang_map['uc'] = [ 'uc' ]
- let s:ex_exvim_lang_map['vim'] = [ 'vim' ]
- let s:ex_exvim_lang_map['wiki'] = [ 'wiki' ]
- let s:ex_exvim_lang_map['xml'] = [ 'xml', 'xsd' ]
- let s:ex_exvim_lang_map['qt'] = [ 'qrc', 'pro', 'pri' ]
- let s:ex_exvim_lang_map['swig'] = [ 'i', 'swg' ]
- " ------------------------------------------------------------------
- " Desc: ctags language file maps
- " ------------------------------------------------------------------
- let s:ex_ctags_lang_map = {}
- let s:ex_ctags_lang_map['asm'] = [ 'asm', 'ASM', 's', 'S', 'A51' ]
- let s:ex_ctags_lang_map['asp'] = [ 'asp', 'asa' ]
- let s:ex_ctags_lang_map['awk'] = [ 'awk', 'gawk', 'mawk' ]
- let s:ex_ctags_lang_map['basic'] = [ 'bas', 'bi', 'bb', 'pb' ]
- let s:ex_ctags_lang_map['beta'] = [ 'bet' ]
- let s:ex_ctags_lang_map['c'] = [ 'c' ]
- let s:ex_ctags_lang_map['cpp'] = [ 'c++', 'cc', 'cp', 'cpp', 'cxx', 'h', 'h++', 'hh', 'hp', 'hpp', 'hxx' ]
- let s:ex_ctags_lang_map['c#'] = [ 'cs' ]
- let s:ex_ctags_lang_map['cobol'] = [ 'cbl', 'cob', 'CBL', 'COB' ]
- let s:ex_ctags_lang_map['eiffel'] = [ 'e' ]
- let s:ex_ctags_lang_map['erlang'] = [ 'erl', 'ERL', 'hrl', 'HRL' ]
- let s:ex_ctags_lang_map['fortran'] = [ 'fo', 'ft', 'f7', 'f9', 'f95' ]
- let s:ex_ctags_lang_map['html'] = [ 'htm', 'html' ]
- let s:ex_ctags_lang_map['java'] = [ 'java' ]
- let s:ex_ctags_lang_map['javascript'] = [ 'js' ]
- let s:ex_ctags_lang_map['lisp'] = [ 'cl', 'clisp', 'el', 'l', 'lisp', 'lsp', 'ml' ]
- let s:ex_ctags_lang_map['lua'] = [ 'lua' ]
- let s:ex_ctags_lang_map['make'] = [ 'mak', 'mk', 'Makefile', 'makefile' ]
- let s:ex_ctags_lang_map['pascal'] = [ 'p', 'pas' ]
- let s:ex_ctags_lang_map['perl'] = [ 'pl', 'pm', 'plx', 'perl' ]
- let s:ex_ctags_lang_map['php'] = [ 'php', 'php3', 'phtml' ]
- let s:ex_ctags_lang_map['python'] = [ 'py', 'pyx', 'pxd', 'scons' ]
- let s:ex_ctags_lang_map['rexx'] = [ 'cmd', 'rexx', 'rx' ]
- let s:ex_ctags_lang_map['ruby'] = [ 'rb', 'ruby' ]
- let s:ex_ctags_lang_map['scheme'] = [ 'SCM', 'SM', 'sch', 'scheme', 'scm', 'sm' ]
- let s:ex_ctags_lang_map['sh'] = [ 'sh', 'SH', 'bsh', 'bash', 'ksh', 'zsh' ]
- let s:ex_ctags_lang_map['slang'] = [ 'sl' ]
- let s:ex_ctags_lang_map['sml'] = ['sml', 'sig' ]
- let s:ex_ctags_lang_map['sql'] = ['sql' ]
- let s:ex_ctags_lang_map['tcl'] = ['tcl', 'tk', 'wish', 'itcl' ]
- let s:ex_ctags_lang_map['vera'] = ['vr', 'vri', 'vrh' ]
- let s:ex_ctags_lang_map['verilog'] = [ 'v' ]
- let s:ex_ctags_lang_map['vim'] = [ 'vim' ]
- let s:ex_ctags_lang_map['yacc'] = [ 'y' ]
- let s:ex_ctags_lang_map['matlab'] = [ 'm' ]
- " ------------------------------------------------------------------
- " Desc: project file filter
- " ------------------------------------------------------------------
- " let s:ex_project_file_filter = 'c,cpp,cxx,c++,C,cc,'
- " let s:ex_project_file_filter .= 'h,H,hh,hxx,hpp,inl,'
- " let s:ex_project_file_filter .= 'cs,'
- " let s:ex_project_file_filter .= 'uc,'
- " let s:ex_project_file_filter .= 'hlsl,vsh,psh,fx,fxh,cg,shd,glsl,'
- " let s:ex_project_file_filter .= 'py,pyw,'
- " let s:ex_project_file_filter .= 'vim,awk,m,'
- " let s:ex_project_file_filter .= 'dox,doxygen,'
- " let s:ex_project_file_filter .= 'ini,cfg,wiki,'
- " let s:ex_project_file_filter .= 'mk,err,exe,bat,sh,'
- " changed by showgood, create my own list of filter
- let s:ex_project_file_filter = 'c,cpp,c++,C,'
- let s:ex_project_file_filter .= 'h,hpp,'
- let s:ex_project_file_filter .= 'py,pyw,vim,awk,sh,bat,err,dll,lib'
- let s:ex_project_file_filter .= 'xml,xsd,ini,cfg,wiki,mak,makefile'
- " ------------------------------------------------------------------
- " Desc: project dir filter
- " ------------------------------------------------------------------
- let s:ex_project_dir_filter = '' " null-string means include all directories
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- " TODO: change to proper variable {
- let s:ex_MapHelpText={}
- let s:ex_MapHelpMode={}
- let s:ex_MapHelpOldMode={}
- let s:ex_MapLastCursorLine={}
- " } TODO end
- "/////////////////////////////////////////////////////////////////////////////
- " window functions
- "/////////////////////////////////////////////////////////////////////////////
- " ------------------------------------------------------------------
- " Desc: Create window
- " buffer_name : a string of the buffer_name
- " window_direction : 'topleft', 'botright'
- " use_vertical : 0, 1
- " edit_mode : 'none', 'append', 'replace'
- " init_func_name: 'none', 'function_name'
- " ------------------------------------------------------------------
- function exUtility#CreateWindow( buffer_name, window_direction, window_size, use_vertical, edit_mode, init_func_name ) " <<<
- " If the window is open, jump to it
- let winnum = bufwinnr(a:buffer_name)
- if winnum != -1
- "Jump to the existing window
- if winnr() != winnum
- exe winnum . 'wincmd w'
- endif
- if a:edit_mode == 'append'
- exe 'normal! G'
- elseif a:edit_mode == 'replace'
- silent exec '1,$d _'
- endif
- return
- endif
- " Create a new window. If user prefers a horizontal window, then open
- " a horizontally split window. Otherwise open a vertically split
- " window
- if a:use_vertical
- " Open a vertically split window
- let win_dir = 'vertical '
- else
- " Open a horizontally split window
- let win_dir = ''
- endif
-
- " If the tag listing temporary buffer already exists, then reuse it.
- " Otherwise create a new buffer
- let bufnum = bufnr(a:buffer_name)
- if bufnum == -1
- " Create a new buffer
- let wcmd = a:buffer_name
- else
- " Edit the existing buffer
- let wcmd = '+buffer' . bufnum
- endif
- " Create the ex_window
- exe 'silent! ' . win_dir . a:window_direction . ' 10' . ' split ' . wcmd
- exe win_dir . 'resize ' . a:window_size
- " Initialize the window
- if bufnum == -1
- call exUtility#InitWindow( a:init_func_name )
- endif
- " Set direction
- let w:use_vertical = a:use_vertical
- let w:window_direction = a:window_direction
- " adjust with edit_mode
- if a:edit_mode == 'append'
- exe 'normal! G'
- elseif a:edit_mode == 'replace'
- silent exec '1,$d _'
- endif
- " after create the window, record the bufname into the plugin buffer name list
- let short_bufname = fnamemodify(a:buffer_name,":p:t")
- if index( g:ex_plugin_registered_bufnames, short_bufname ) == -1
- silent call add( g:ex_plugin_registered_bufnames, short_bufname )
- endif
- " record the filetype into the plugin filetype list
- let buf_filetype = getbufvar(a:buffer_name,'&filetype')
- if index( g:ex_plugin_registered_filetypes, buf_filetype ) == -1
- silent call add( g:ex_plugin_registered_filetypes, buf_filetype )
- endif
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc: Init window
- " init_func_name: 'none', 'function_name'
- " ------------------------------------------------------------------
- function exUtility#InitWindow(init_func_name) " <<<
- silent! setlocal filetype=ex_plugin
- " Folding related settings
- silent! setlocal foldenable
- silent! setlocal foldminlines=0
- silent! setlocal foldmethod=manual
- silent! setlocal foldlevel=9999
- " Mark buffer as scratch
- silent! setlocal buftype=nofile
- silent! setlocal bufhidden=hide
- silent! setlocal noswapfile
- silent! setlocal nobuflisted
- silent! setlocal nowrap
- " If the 'number' option is set in the source window, it will affect the
- " exTagSelect window. So forcefully disable 'number' option for the exTagSelect
- " window
- silent! setlocal nonumber
- " the winfix height width will let plugin-window not join into the <c-w>= operations
- silent! setlocal winfixheight
- silent! setlocal winfixwidth
- " Define the ex autocommands
- augroup ex_auto_cmds
- autocmd WinLeave * call exUtility#RecordCurrentBufNum()
- autocmd BufLeave * call exUtility#RecordSwapBufInfo()
- augroup end
- " avoid cwd change problem
- if exists( 'g:exES_CWD' )
- "au BufEnter * silent exec 'lcd ' . escape(g:exES_CWD, " ")
- endif
- " call the user define init_function
- if a:init_func_name != 'none'
- exe 'call ' . a:init_func_name . '()'
- endif
- " Define syntax highlight
- " NOTE: define the syntax highlight after user init. this can prevent user
- " override the basic syntax.
- syntax match ex_SynError '^Error:.*'
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc: Open window
- " buffer_name : a string of the buffer_name
- " window_direction : 'topleft', 'botright'
- " use_vertical : 0, 1
- " edit_mode : 'none', 'append', 'replace'
- " backto_editbuf : 0, 1
- " init_func_name: 'none', 'function_name'
- " call_func_name: 'none', 'function_name'
- " ------------------------------------------------------------------
- function exUtility#OpenWindow( buffer_name, window_direction, window_size, use_vertical, edit_mode, backto_editbuf, init_func_name, call_func_name ) " <<<
- " close ex_plugin window in same position
- call exUtility#ClosePluginWindowInSamePosition ( a:use_vertical, a:window_direction )
- " go to edit buffer first, then open the window, this will avoid some bugs
- call exUtility#RecordCurrentBufNum()
- call exUtility#GotoEditBuffer()
- " If the window is open, jump to it
- let winnum = bufwinnr(a:buffer_name)
- if winnum != -1
- " Jump to the existing window
- if winnr() != winnum
- exe winnum . 'wincmd w'
- endif
- if a:edit_mode == 'append'
- exe 'normal! G'
- elseif a:edit_mode == 'replace'
- silent exec '1,$d _'
- endif
- return
- endif
- " Open window
- call exUtility#CreateWindow( a:buffer_name, a:window_direction, a:window_size, a:use_vertical, a:edit_mode, a:init_func_name )
- if a:call_func_name != 'none'
- exe 'call ' . a:call_func_name . '()'
- endif
- "
- if a:backto_editbuf
- " Need to jump back to the original window only if we are not
- " already in that window
- call exUtility#GotoEditBuffer()
- endif
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc: Close window
- " ------------------------------------------------------------------
- function exUtility#CloseWindow( buffer_name ) " <<<
- "Make sure the window exists
- let winnum = bufwinnr(a:buffer_name)
- if winnum == -1
- call exUtility#WarningMsg('Error: ' . a:buffer_name . ' window is not open')
- return
- endif
- " close window
- exe winnum . 'wincmd w'
- " if this is not the only window
- if winbufnr(2) != -1
- " If a window other than the a:buffer_name window is open,
- " then only close the a:buffer_name window.
- close
- endif
- " go back to edit buffer
- call exUtility#GotoEditBuffer()
- call exUtility#ClearObjectHighlight()
-
- "if winnr() == winnum
- " let last_buf_num = bufnr('#')
- " " Already in the window. Close it and return
- " if winbufnr(2) != -1
- " " If a window other than the a:buffer_name window is open,
- " " then only close the a:buffer_name window.
- " close
- " endif
- " " Need to jump back to the original window only if we are not
- " " already in that window
- " let winnum = bufwinnr(last_buf_num)
- " if winnr() != winnum
- " exe winnum . 'wincmd w'
- " endif
- "else
- " " Goto the a:buffer_name window, close it and then come back to the
- " " original window
- " let cur_buf_num = bufnr('%')
- " exe winnum . 'wincmd w'
- " close
- " " Need to jump back to the original window only if we are not
- " " already in that window
- " let winnum = bufwinnr(cur_buf_num)
- " if winnr() != winnum
- " exe winnum . 'wincmd w'
- " endif
- "endif
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc: Toggle window
- " ------------------------------------------------------------------
- function exUtility#ToggleWindow( buffer_name, window_direction, window_size, use_vertical, edit_mode, backto_editbuf, init_func_name, call_func_name ) " <<<
- " If exTagSelect window is open then close it.
- let winnum = bufwinnr(a:buffer_name)
- if winnum != -1
- call exUtility#CloseWindow(a:buffer_name)
- return
- endif
- call exUtility#OpenWindow( a:buffer_name, a:window_direction, a:window_size, a:use_vertical, a:edit_mode, a:backto_editbuf, a:init_func_name, a:call_func_name )
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc: Resize window use increase value
- " ------------------------------------------------------------------
- function exUtility#ResizeWindow( use_vertical, original_size, increase_size ) " <<<
- if a:use_vertical
- let new_size = a:original_size
- if winwidth('.') <= a:original_size
- let new_size = a:original_size + a:increase_size
- endif
- silent exe 'vertical resize ' . new_size
- else
- let new_size = a:original_size
- if winheight('.') <= a:original_size
- let new_size = a:original_size + a:increase_size
- endif
- silent exe 'resize ' . new_size
- endif
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#OperateWindow( title, close_when_selected, backto_edibut, hl_obj_line ) " <<<
- if a:close_when_selected
- call exUtility#CloseWindow(a:title)
- call exUtility#GotoEditBuffer()
- else
- " go back to edit buffer first
- call exUtility#GotoEditBuffer()
- " highlight object line when
- " 1: we not close selected window
- " 2: if we needed
- if a:hl_obj_line
- call exUtility#HighlightObjectLine()
- exe 'normal! zz'
- endif
- " if not back to edit buffer, we jump back to specificed window
- if !a:backto_edibut
- let winnum = bufwinnr(a:title)
- if winnr() != winnum
- exe winnum . 'wincmd w'
- endif
- endif
- endif
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#ClosePluginWindowInSamePosition ( use_vertical, window_direction ) " <<<
- " NOTE: the CloseWindow should be called in each situation.
- " Since you can: in a exProject/Minibuffer window try to open another plugin window.
- " or just open a plugin window that already have another plugin window take the position.
- " check if a ex window exists on the target position, if yes, close it.
- for nr_win in range(1,winnr("$"))
- if getwinvar(nr_win, "use_vertical") == a:use_vertical && getwinvar(nr_win, "window_direction") == a:window_direction
- " get the ex window, change window to the target window
- silent exe nr_win . 'wincmd w'
- call exUtility#CloseWindow( bufname('%') )
- return
- endif
- endfor
- " check if current window is a plugin window ( except minibuf, exProject), if yes close it
- if exUtility#IsRegisteredPluginBuffer ( bufname('%') ) &&
- \ fnamemodify(bufname('%'),":p:t") !=# "-MiniBufExplorer-" &&
- \ &filetype != 'ex_project' &&
- \ &filetype != 'nerdtree'
- call exUtility#CloseWindow( bufname('%') )
- return
- endif
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#CloseAllExpluginWindow() " <<<
- " walk through all window in exvim
- let i = 1
- let bufnum_list = []
- while i <= winnr("$")
- let bnum = winbufnr(i)
- let buf_filetype = getbufvar(bnum, '&filetype')
- if bnum != -1 && exUtility#IsRegisteredPluginBuffer ( bufname('%') )
- silent call add ( bufnum_list, bnum )
- endif
- let i += 1
- endwhile
- "
- for bnum in bufnum_list
- call exUtility#CloseWindow ( bufname(bnum) )
- endfor
- endfunction " >>>
- "/////////////////////////////////////////////////////////////////////////////
- " string functions
- "/////////////////////////////////////////////////////////////////////////////
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#PutLine( len, line_type ) " <<<
- let plen = a:len - strlen(getline('.'))
- if (plen > 0)
- execute 'normal! ' plen . 'A' . a:line_type
- endif
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#PutSegment() " <<<
- silent normal! o''
- let space = printf('%*s',indent('.'),'')
- silent call setline ( '.', space . b:ECcommentOpen . "/////////////////////////////////////////////////////////////////////////////" . b:ECcommentClose )
- silent call append ( '.', space . b:ECcommentOpen . "" . b:ECcommentClose )
- silent normal! j
- silent call append ( '.', space . b:ECcommentOpen . "/////////////////////////////////////////////////////////////////////////////" . b:ECcommentClose )
- silent normal! j
- silent call append ( '.', "" )
- silent normal! j
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#PutNote() " <<<
- silent normal! o''
- let space = printf('%*s',indent('.'),'')
- silent call setline ( '.', space . b:ECcommentOpen . " ############################################################################ " . b:ECcommentClose )
- silent call append ( '.', space . b:ECcommentOpen . " Note: " . b:ECcommentClose )
- silent normal! j
- silent call append ( '.', space . b:ECcommentOpen . " ############################################################################ " . b:ECcommentClose )
- silent normal! j
- silent call append ( '.', "" )
- silent normal! j
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#PutNamespaceStart( space_name ) " <<<
- silent call append ( '.', b:ECcommentOpen . " ######################### " . b:ECcommentClose )
- silent normal! j
- silent call append ( '.', "namespace " . a:space_name . " { " )
- silent normal! j
- silent call append ( '.', b:ECcommentOpen . " ######################### " . b:ECcommentClose )
- silent normal! j
- silent call append ( '.', "" )
- silent normal! j
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#PutNamespaceEnd( space_name ) " <<<
- silent call append ( '.', b:ECcommentOpen . " ######################### " . b:ECcommentClose )
- silent normal! j
- silent call append ( '.', "} // end namespace " . a:space_name . " " )
- silent normal! j
- silent call append ( '.', b:ECcommentOpen . " ######################### " . b:ECcommentClose )
- silent normal! j
- silent call append ( '.', "" )
- silent normal! j
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#PutNamespace( space_name, line1, line2 ) " <<<
- "
- let first_line = a:line1
- let last_line = a:line2
- " put namespace end first
- silent call cursor( last_line, 1 )
- silent put = ''
- call exUtility#PutNamespaceEnd(a:space_name)
- " then go back to first line and put namespace start
- silent call cursor( first_line - 1, 1 )
- call exUtility#PutNamespaceStart(a:space_name)
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#PutExternC( line1, line2 ) " <<<
- "
- let first_line = a:line1
- let last_line = a:line2
- " put namespace end first
- silent call cursor( last_line, 1 )
- silent put = ''
- silent call append ( '.', b:ECcommentOpen . " ######################### " . b:ECcommentClose )
- silent normal! j
- silent call append ( '.', "#ifdef __cplusplus" )
- silent normal! j
- silent call append ( '.', "} // end extern C " )
- silent normal! j
- silent call append ( '.', "#endif" )
- silent normal! j
- silent call append ( '.', b:ECcommentOpen . " ######################### " . b:ECcommentClose )
- silent normal! j
- silent call append ( '.', "" )
- silent normal! j
- " then go back to first line and put namespace start
- silent call cursor( first_line - 1, 1 )
- silent call append ( '.', b:ECcommentOpen . " ######################### " . b:ECcommentClose )
- silent normal! j
- silent call append ( '.', "#ifdef __cplusplus" )
- silent normal! j
- silent call append ( '.', 'extern "C" { ' )
- silent normal! j
- silent call append ( '.', "#endif" )
- silent normal! j
- silent call append ( '.', b:ECcommentOpen . " ######################### " . b:ECcommentClose )
- silent normal! j
- silent call append ( '.', "" )
- silent normal! j
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#PutSeparate() " <<<
- silent normal! o''
- let space = printf('%*s',indent('.'),'')
- silent call setline ( '.', space . b:ECcommentOpen . " ======================================================== " . b:ECcommentClose )
- silent call append ( '.', space . b:ECcommentOpen . " " . b:ECcommentClose )
- silent normal! j
- silent call append ( '.', space . b:ECcommentOpen . " ======================================================== " . b:ECcommentClose )
- silent normal! j
- silent call append ( '.', "" )
- silent normal! j
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#PutDescription() " <<<
- silent normal! o''
- let space = printf('%*s',indent('.'),'')
- silent call setline ( '.', space . b:ECcommentOpen . " ------------------------------------------------------------------ " . b:ECcommentClose )
- silent call append ( '.', space . b:ECcommentOpen . " Desc: " . b:ECcommentClose )
- silent normal! j
- silent call append ( '.', space . b:ECcommentOpen . " ------------------------------------------------------------------ " . b:ECcommentClose )
- silent normal! j
- silent call append ( '.', "" )
- silent normal! j
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#PutDefine() " <<<
- silent normal! o''
- let space = printf('%*s',indent('.'),'')
- silent call setline ( '.', space . b:ECcommentOpen . " ------------------------------------------------------------------ " . b:ECcommentClose )
- silent call append ( '.', space . b:ECcommentOpen . " Desc: " . b:ECcommentClose )
- silent normal! j
- silent call append ( '.', space . b:ECcommentOpen . " ------------------------------------------------------------------ " . b:ECcommentClose )
- silent normal! j
- silent call append ( '.', "" )
- silent normal! j
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#PutDeclaration() " <<<
- silent normal! o''
- let space = printf('%*s',indent('.'),'')
- silent call setline ( '.', space . b:ECcommentOpen . "/////////////////////////////////////////////////////////////////////////////" . b:ECcommentClose )
- silent call append ( '.', space . b:ECcommentOpen . " class " . b:ECcommentClose )
- silent normal! j
- silent call append ( '.', space . b:ECcommentOpen . " " . b:ECcommentClose )
- silent normal! j
- silent call append ( '.', space . b:ECcommentOpen . " Purpose: " . b:ECcommentClose )
- silent normal! j
- silent call append ( '.', space . b:ECcommentOpen . " " . b:ECcommentClose )
- silent normal! j
- silent call append ( '.', space . b:ECcommentOpen . "/////////////////////////////////////////////////////////////////////////////" . b:ECcommentClose )
- silent normal! j
- silent call append ( '.', "" )
- silent normal! j
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#PutHeader() " <<<
- let old_lan = v:lang
- silent exec 'language C'
- if getline(1) =~# b:ECcommentOpen . " ======================================================================================" . b:ECcommentClose
- if getline(2) =~# b:ECcommentOpen . " File : .*" . b:ECcommentClose
- if getline(3) =~# b:ECcommentOpen . " Author : .*" . b:ECcommentClose
- if getline(4) =~# b:ECcommentOpen . " Last Change : .*" . b:ECcommentClose
- if getline(5) =~# b:ECcommentOpen . " Description : .*" . b:ECcommentClose
- silent call setline ( 2, b:ECcommentOpen . " File : " . fnamemodify(expand('%'), ":t") . b:ECcommentClose )
- silent call setline ( 3, b:ECcommentOpen . " Author : " . g:ex_usr_name . " " . b:ECcommentClose )
- silent call setline ( 4, b:ECcommentOpen . " Last Change : " . strftime("%m/%d/%Y | %H:%M:%S %p | %A,%B") . b:ECcommentClose )
- silent call cursor ( 7, 0 )
- return
- endif
- endif
- endif
- endif
- endif
- silent call append ( 0, b:ECcommentOpen . " ======================================================================================" . b:ECcommentClose )
- silent call append ( 1, b:ECcommentOpen . " File : " . fnamemodify(expand('%'), ":t") . b:ECcommentClose )
- silent call append ( 2, b:ECcommentOpen . " Author : " . g:ex_usr_name . " " . b:ECcommentClose )
- silent call append ( 3, b:ECcommentOpen . " Last Change : " . strftime("%m/%d/%Y | %H:%M:%S %p | %A,%B") . b:ECcommentClose )
- silent call append ( 4, b:ECcommentOpen . " Description : " . b:ECcommentClose )
- silent call append ( 5, b:ECcommentOpen . " ======================================================================================" . b:ECcommentClose )
- silent call append ( 6, "" )
- silent call cursor ( 7, 0 )
- " FIXME: cannot reset {
- " silent exec 'language ' . old_lan
- " } FIXME end
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#PutMain() " <<<
- execute 'normal! ' . 'o' . "int main( int argc, char* argv[] )"
- execute 'normal! ' . "o" . "{"
- execute 'normal! ' . "o" . "}\<CR>"
- execute 'normal! ' . "2k"
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#PutClass( class_type, class_name ) " <<<
- execute 'normal! ' . 'o' . "///////////////////////////////////////////////////////////////////////////////"
- execute 'normal! ' . 'o' . "// class " . a:class_name
- execute 'normal! ' . 'o' . "// "
- execute 'normal! ' . 'o' . "// Purpose: "
- execute 'normal! ' . 'o' . "// "
- execute 'normal! ' . 'o' . "///////////////////////////////////////////////////////////////////////////////"
- execute 'normal! ' . 'o'
- execute 'normal! ' . 'o' . a:class_type . " " . a:class_name
- execute 'normal! ' . 'o' . "{"
- execute 'normal! ' . 'o' . "public:"
- execute 'normal! ' . 'o' . "// internal typedef"
- execute 'normal! ' . 'o' . "typedef " . a:class_name . " self_t;"
- execute 'normal! ' . 'o'
- execute 'normal! ' . 'o' . "public:"
- execute 'normal! ' . 'o' . "// con/de-structor"
- execute 'normal! ' . 'o' . a:class_name . " ();"
- execute 'normal! ' . 'o' . "virtual ~" . a:class_name . " ();"
- execute 'normal! ' . 'o'
- execute 'normal! ' . 'o' . "public:"
- execute 'normal! ' . 'o' . "// copy constructor"
- execute 'normal! ' . 'o' . a:class_name . " ( const self_t& _copy );"
- execute 'normal! ' . 'o' . "self_t& operator = ( const self_t& _copy );"
- execute 'normal! ' . 'o'
- execute 'normal! ' . 'o' . "}; // end " . a:class_type . " " . a:class_name
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#MarkText( text, line1, line2 ) " <<<
- "
- let first_line = a:line1
- let last_line = a:line2
- " check if it is special mark, special mark will use uppercase
- let text = ''
- for item in split(a:text, ' ')
- if item =~? s:ex_special_mark_pattern
- let text .= toupper(item) . ' '
- else
- let text .= item . ' '
- endif
- endfor
- " remove last space
- let text = strpart ( text, 0, len(text) - 1 )
- "
- let lstline = last_line + 1
- let space = printf('%*s',indent(first_line),'')
- call append( last_line , space . b:ECcommentOpen . ' } ' . text . ' end ' . b:ECcommentClose )
- call append( first_line -1 , space . b:ECcommentOpen . ' ' . text . ' { ' . b:ECcommentClose )
- silent exec ":" . lstline
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#RemoveSpecialMarkText () " <<<
- let save_cursor = getpos(".")
- let save_line = getline(".")
- let cur_line = save_line
- let start_lnum = -1
- let end_lnum = -1
- let start_pattern = b:ECcommentOpen . '.*' . '\(' . s:ex_special_mark_pattern . '\)' . '.* { ' . b:ECcommentClose
- let end_pattern = b:ECcommentOpen . ' }.*' . '\(' . s:ex_special_mark_pattern . '\)' . '.* end ' . b:ECcommentClose
- " found '#if 0' first
- while match(cur_line, start_pattern ) == -1
- let cur_line_nr = line(".")
- silent normal! ^[{
- let cur_line = getline(".")
- let lnum = line(".")
- if lnum == cur_line_nr
- if match( cur_line, start_pattern ) == -1
- call exUtility#WarningMsg("special mark pattern not found")
- silent call cursor(save_cursor[1], save_cursor[2])
- return
- endif
- endif
- endwhile
- " record the line
- let start_lnum = line(".")
- silent normal! $]}
- let end_lnum = line(".")
- " delete the if/else/endif
- if end_lnum != -1
- silent exe end_lnum
- silent normal! dd
- endif
- if start_lnum != -1
- silent exe start_lnum
- silent normal! dd
- endif
- silent call setpos('.', save_cursor)
- if match(save_line, start_pattern) == -1 && match(save_line, end_pattern) == -1
- silent call search('\V'.save_line, 'b')
- endif
- silent call cursor(line('.'), save_cursor[2])
- if match(save_line, end_pattern) != -1
- silent normal! kk
- endif
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#AlignDigit( align_nr, digit ) " <<<
- let print_fmt = '%'.a:align_nr.'d'
- let str_digit = printf(print_fmt,a:digit)
- retur substitute(str_digit,' ', '0','g')
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#InsertIFZero() range " <<<
- let lstline = a:lastline + 1
- call append( a:lastline , "#endif")
- call append( a:firstline -1 , "#if 0")
- silent exec ":" . lstline
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#RemoveIFZero() range " <<<
- " FIXME: when line have **, it will failed
- let save_cursor = getpos(".")
- let save_line = getline(".")
- let cur_line = save_line
- let if_lnum = -1
- let else_lnum = -1
- let endif_lnum = -1
- " found '#if 0' first
- while match(cur_line, "#if.*0") == -1
- let cur_line_nr = line(".")
- silent normal! [#
- let cur_line = getline(".")
- let lnum = line(".")
- if lnum == cur_line_nr
- if match(cur_line, "#if.*0") == -1
- call exUtility#WarningMsg(" not #if 0 matched")
- silent call cursor(save_cursor[1], save_cursor[2])
- return
- endif
- endif
- endwhile
- " record the line
- let if_lnum = line(".")
- silent normal! ]#
- let cur_line = getline(".")
- if match(cur_line, "#else") != -1
- let else_lnum = line(".")
- silent normal! ]#
- let endif_lnum = line(".")
- else
- let endif_lnum = line(".")
- endif
- " delete the if/else/endif
- if endif_lnum != -1
- silent exe endif_lnum
- silent normal! dd
- endif
- if else_lnum != -1
- silent exe else_lnum
- silent call setline('.',"// XXX #else XXX")
- endif
- if if_lnum != -1
- silent exe if_lnum
- silent normal! dd
- endif
- silent call setpos('.', save_cursor)
- if match(save_line, "#if.*0") == -1 && match(save_line, "#endif.*") == -1
- silent call search('\V'.save_line, 'b')
- endif
- silent call cursor(line('.'), save_cursor[2])
- if match(save_line, "#endif.*") != -1
- silent normal! kk
- endif
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc: TODO: check if the last character is space, if not, add space
- " TODO: used the longest column as the base column to insert \
- " ------------------------------------------------------------------
- function exUtility#InsertRemoveExtend() range " <<<
- let line = getline('.')
- if (strpart(line,strlen(line)-1,1) == "\\")
- exec ":" . a:firstline . "," . a:lastline . "s/\\\\$//"
- else
- exec ":" . a:firstline . "," . a:lastline . "s/$/ \\\\/"
- endif
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#Yank( string ) " <<<
- let @" = a:string
- let @* = a:string
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#SmartCaseCompare( text, pattern ) " <<<
- if match(a:pattern, '\u') != -1 " if we have upper case, use case compare
- return match ( a:text, '\C'.a:pattern ) != -1
- else " ignore case compare
- return match ( a:text, a:pattern ) != -1
- endif
- endfunction " >>>
- "/////////////////////////////////////////////////////////////////////////////
- " buffer functions
- "/////////////////////////////////////////////////////////////////////////////
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#IsRegisteredPluginBuffer ( buffer_name ) " <<<
- " check if the buffer filetype is register in the plugin filetype list
- if index( g:ex_plugin_registered_filetypes, getbufvar( a:buffer_name, '&filetype' ), 0, 1 ) >= 0
- return 1
- endif
- " check if the buffer name is register in the plugin buffername list
- if index( g:ex_plugin_registered_bufnames, fnamemodify( a:buffer_name, ":p:t" ), 0, 1 ) >= 0
- return 1
- endif
- return 0
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc: Record current buf num when leave
- " FIXME: when you split window/open the same file in two window, you can only get the original bufwinnr() by the bufnr().
- " FIXME: :sp will trigger the WinEnter, find a way to use it.
- " ------------------------------------------------------------------
- function exUtility#RecordCurrentBufNum() " <<<
- let short_bufname = fnamemodify(bufname('%'),":p:t")
- if !exUtility#IsRegisteredPluginBuffer(bufname('%'))
- let s:ex_editbuf_num = bufnr('%')
- elseif short_bufname !=# "-MiniBufExplorer-"
- let s:ex_pluginbuf_num = bufnr('%')
- endif
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc: Record current buf pos
- " ------------------------------------------------------------------
- function exUtility#RecordSwapBufInfo() " <<<
- let bufnr = bufnr('%')
- let short_bufname = fnamemodify(bufname(bufnr),":p:t")
- if buflisted(bufnr) && bufloaded(bufnr) && bufexists(bufnr) && !exUtility#IsRegisteredPluginBuffer(bufname('%'))
- let s:ex_swap_buf_num = bufnr
- let s:ex_swap_buf_pos = getpos('.')
- endif
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#SwapToLastEditBuffer() " <<<
- " check if current buffer can use switch
- let cur_bufnr = bufnr('%')
- let cru_short_bufname = fnamemodify(bufname('%'),":p:t")
- if exUtility#IsRegisteredPluginBuffer ( bufname('%') ) " check it is plugin window or not
- call exUtility#WarningMsg("Buffer: " .bufname(cur_bufnr). " can't be switch.")
- return
- endif
- " check if last buffer existed and listed, swap if accessable
- let last_bufnr = bufnr("#")
- let last_short_bufname = fnamemodify(bufname(last_bufnr),":p:t")
- if buflisted(last_bufnr) && bufloaded(last_bufnr) && bufexists(last_bufnr) && !exUtility#IsRegisteredPluginBuffer(bufname('%'))
- let tmp_swap_buf_pos = deepcopy(s:ex_swap_buf_pos)
- let tmp_swap_buf_nr = s:ex_swap_buf_num
- let s:ex_swap_buf_pos = getpos('.')
- silent exec last_bufnr."b!"
- " only recover the pos when we have the right last buffer recorded
- if last_bufnr == tmp_swap_buf_nr
- silent call setpos('.',tmp_swap_buf_pos)
- endif
- else
- call exUtility#WarningMsg("Buffer: " .bufname(last_bufnr). " can't be accessed.")
- endif
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#GotoBuffer(cmd) " <<<
- " NOTE: there has a bug, in window (not fullscree) mode, some times the buffer will jump to other display screen ( if you use double screen ).
- " save current win pos x,y.
- if has("gui_running")
- let gui_win_pos_x = getwinposx()
- let gui_win_pos_y = getwinposy()
- endif
- " if this is a registered plugin buffer, then go to the edit buffer first
- if exUtility#IsRegisteredPluginBuffer(bufname('%'))
- call exUtility#GotoEditBuffer()
- endif
- " jump buffer
- if a:cmd ==# 'next'
- silent exec "bn!"
- elseif a:cmd ==# 'prev'
- silent exec "bp!"
- endif
- " restore windows pos if needed ( if windows pos changed )
- if has("gui_running")
- if gui_win_pos_x != getwinposx() || gui_win_pos_y != getwinposy()
- silent exec "winpos " . gui_win_pos_x " " . gui_win_pos_y
- endif
- endif
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc: Update current buffer
- " ------------------------------------------------------------------
- function exUtility#UpdateCurrentBuffer() " <<<
- if exists(':UMiniBufExplorer')
- silent exe "UMiniBufExplorer"
- endif
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#GotoEditBuffer() " <<<
- " check and jump to the buffer first
- let winnum = bufwinnr(s:ex_editbuf_num)
- if winnr() != winnum && winnum != -1 " this will fix the jump error in the vimentry buffer, cause the winnum for vimentry buffer will be -1
- exe winnum . 'wincmd w'
- endif
- call exUtility#RecordCurrentBufNum()
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#GotoPluginBuffer() " <<<
- " check and jump to the buffer first
- let winnum = bufwinnr(s:ex_pluginbuf_num)
- if winnr() != winnum
- exe winnum . 'wincmd w'
- endif
- call exUtility#RecordCurrentBufNum()
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#GetEditBufferNum() " <<<
- return s:ex_editbuf_num
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#YankBufferNameForCode() " <<<
- let buf_name = exUtility#Pathfmt( bufname('%'), 'unix' )
- silent call exUtility#Yank( fnamemodify(buf_name,"") )
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#YankFilePathForCode() " <<<
- let buf_name = exUtility#Pathfmt( bufname('%'), 'unix' )
- silent call exUtility#Yank( fnamemodify(buf_name,":h") )
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#SwitchBuffer() " <<<
- " this will fix no jump error < bufwinnr() == -1 >
- silent call exUtility#RecordCurrentBufNum()
- " if current window is same as edit buffer window, jump to last edit window
- if winnr() == bufwinnr(s:ex_editbuf_num)
- call exUtility#GotoPluginBuffer()
- else
- call exUtility#GotoEditBuffer()
- endif
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc: VimTip #1119: How to use Vim like an IDE
- " delete the buffer; keep windows; create a scratch buffer if no buffers left
- " Using this Kwbd function (:call Kwbd(1)) will make Vim behave like an IDE; or maybe even better.
- " ------------------------------------------------------------------
- function exUtility#Kwbd(kwbdStage) " <<<
- if(a:kwbdStage == 1)
- " check it is plugin window, if yes, close it directly to prevent use \bd
- " close, reopen will loose plugin ability problem
- let cru_short_bufname = fnamemodify(bufname('%'),":p:t")
- if exUtility#IsRegisteredPluginBuffer(bufname('%'))
- silent exec 'close'
- call exUtility#GotoEditBuffer()
- return
- endif
- "
- if(!buflisted(winbufnr(0)))
- bd!
- return
- endif
- let g:kwbdBufNum = bufnr("%")
- let g:kwbdWinNum = winnr()
- windo call exUtility#Kwbd(2)
- exe g:kwbdWinNum . 'wincmd w'
- let g:buflistedLeft = 0
- let g:bufFinalJump = 0
- let l:nBufs = bufnr("$")
- let l:i = 1
- while(l:i <= l:nBufs)
- if(l:i != g:kwbdBufNum)
- if(buflisted(l:i))
- let g:buflistedLeft = g:buflistedLeft + 1
- else
- if(bufexists(l:i) && !strlen(bufname(l:i)) && !g:bufFinalJump)
- let g:bufFinalJump = l:i
- endif
- endif
- endif
- let l:i = l:i + 1
- endwhile
- if(!g:buflistedLeft)
- if(g:bufFinalJump)
- windo if(buflisted(winbufnr(0))) | execute "b! " . g:bufFinalJump | endif
- else
- enew
- let l:newBuf = bufnr("%")
- windo if(buflisted(winbufnr(0))) | execute "b! " . l:newBuf | endif
- endif
- exe g:kwbdWinNum . 'wincmd w'
- endif
- if(buflisted(g:kwbdBufNum) || g:kwbdBufNum == bufnr("%"))
- execute "bd! " . g:kwbdBufNum
- endif
- if(!g:buflistedLeft)
- set buflisted
- set bufhidden=delete
- set buftype=nofile
- setlocal noswapfile
- normal athis is the scratch buffer
- endif
- else
- if(bufnr("%") == g:kwbdBufNum)
- let prevbufvar = bufnr("#")
- if(prevbufvar > 0 && buflisted(prevbufvar) && prevbufvar != g:kwbdBufNum)
- b #
- else
- bn
- endif
- endif
- endif
- endfunction " >>>
- " ------------------------------------------------------------------
- " Desc:
- " ------------------------------------------------------------------
- function exUtility#SaveRestoreInfo() " <<<
- if exists ('g:exES_RestoreInfo')
- let nb_buffers = bufnr('$') " Get the number of the last buffer.
- let idx = 1 " Set the buffer index to one, NOTE: zero is represent to last edit buffer.
- let cmdlist = []
- " store liste