set term=xtermc
set visualbell
set nows
highlight Search term=standout  ctermfg=1 ctermbg=3 guifg=Blue guibg=Yellow



highlight DiffText term=bold ctermbg=5 guibg=LightMagenta
"highlight DiffDelete     xxx term=bold cterm=bold ctermfg=4 ctermbg=6 gui=bold guifg=Blue guibg=LightCyan
highlight DiffChange term=reverse cterm=bold ctermbg=12 gui=bold guibg=Red



set hlsearch
set ruler
set guioptions-=T
set wrap
set diffopt=iwhite,filler
"to turn off menu, and left, right, bottom scrollbars:
set guioptions-=m      
set guioptions-=l
set guioptions-=r
set guioptions-=b
set incsearch
set guifont=7x13
syntax on
command! -nargs=+ Xfind 'a,'b w! Xfind_mmm.txt | vsplit Xfind_mmm.txt |vert res | / 

function! XlFunction( )
    let currentLineNumber = line(".")
    execute "!/home/xji01/VNC/xtermOnBuildMachine -name XLarge -sl 10000 -vb -fn 8x13 -bg black -fg white -geometry 172x70+0+22 -e vim -X % "." +".currentLineNumber." &"

endfunction

command! -nargs=0 Xl call XlFunction()

command! -nargs=+ Xsyntax syntax keyword diffadd 
"set lines=45
"to get DiffAdd color correctly, set background=dark then background=light

set showcmd
"syntax region ErrorMsg start="xjia" end="xjib"
set background&
set textwidth=78
set laststatus=2

"to quickly go to SystemDB.sql and SystemDB.txt
"source ~/CONST.vim
"===============================================================
"For backslash: use double backslashes like: \\
"
function! Grep2Helper(startString, endString, ...)
    let lineNumberOfFile = line("$")
    let i = 1
    let temp = delete("Xgrep_mmm.txt")
    let matchedBlockLines=""
    let finalSaveLines=""
    let startStringFound = 0
    let matchedBlockNumber = 0
    if a:0 > 0   "at least one extra argument
        let middleString = a:1
    endif
    while i <= lineNumberOfFile
        let lineText = getline(i)
        "echo i lineText matchedBlockNumber
        
        if lineText =~ a:endString && startStringFound
            let matchedBlockLines = matchedBlockLines.lineText."\"
            if a:0 > 0   "at least one extra argument
                if matchedBlockLines =~ a:1
                    let finalSaveLines=finalSaveLines.matchedBlockLines."\"
                    let matchedBlockNumber = matchedBlockNumber + 1
                endif
            else
                let finalSaveLines = finalSaveLines.matchedBlockLines."\"
                let matchedBlockNumber = matchedBlockNumber + 1
            endif
            let matchedBlockLines = ""
            let startStringFound = 0
            let i = i + 1
            continue
        endif
        if lineText =~ a:startString
            let startStringFound = 1
        endif
        if startStringFound == 1
            let matchedBlockLines = matchedBlockLines.lineText."\"
        endif
        let i = i + 1
    endwhile
    call setreg('a', "")
    if startStringFound == 1 "startString found, but endString not found
                            "still need to dump it out
        let finalSaveLines = finalSaveLines.matchedBlockLines
    endif
    if finalSaveLines != ""
        call setreg('a', finalSaveLines)
        new Xgrep_mmm.txt
	execute "normal \"aP"
        execute "normal \\"
        echo matchedBlockNumber . " block(s) found, \"ap to see results"
    else
        echo "Unable to find any blocks!"
    endif
    "echo matchedBlockLines
    "call append(0, matchedBlockLines)
    return matchedBlockNumber
endfunction

function! Grep2(startString, endString, ...)
    if a:0 > 0   "at least one extra argument
        call Grep2Helper(a:startString, a:endString, a:1)
    else
        call Grep2Helper(a:startString, a:endString)
    endif 
endfunction



"===============================================================
function! SearchBlock( ) "to highligh a block to search
    let xjistartnumber = 0 
    let xjiendnumber = 0
    1 "go to first line
    while search("xjistart", "W") > 0
        let xjistartnumber = xjistartnumber + 1
    endwhile
    while search("xjiend", "W") > 0
        let xjiendnumber = xjiendnumber + 1
    endwhile
    echo xjistartnumber . " xjistart found, " . xjiendnumber . " xjiend found"
    syntax region Question start="xjistart" end="xjiend"
    syntax sync fromstart
endfunction

command! -nargs=0 Xb call SearchBlock ( )

function! SearchBlockEnd( )
    let currentLineNumber = line(".")
    1
    while search("xjistart\\|xjiend", "W") > 0  
        let currentline = getline ( "." )
        let userinput = input(currentline . "\nDo you want to remove whole line(y/n/q)? " )
	if userinput == 'y'
	    execute "normal dd"
	    redraw
        elseif userinput == 'q'
	    break
	endif
    endwhile
    call cursor(currentLineNumber, 1) 
endfunction

command! -nargs=0 Xe call SearchBlockEnd ( )

"============================================
"Just to highlight a word under the cursor: call Xs()
"To turn the highlight off: call Xs("mmmmmmmmmmmmmmmmmmmmm")
function! Xs(...) " can be deleted now!!!
    if a:0 == 0 
        execute "match diffadd /". expand("") . "/"
    elseif a:0 == 1
        execute "match diffadd /". a:1 . "/"
    endif
endfunction

map  :call Xs()


function! Xh(...)
    if a:0 == 0 
        execute "syntax match diffadd /". expand("")."/"
    elseif a:0 == 1
        if a:1 == 1 
            execute "syntax match DiffDelete /". expand("")."/"
        elseif a:1 == 2
            execute "syntax match DiffText /". expand("")."/"
        elseif a:1 == 3
            execute "syntax match Error /". expand("")."/"
        elseif a:1 == 4
            execute "syntax match WildMenu /". expand("")."/"
        elseif a:1 == 5
            execute "syntax match IncSearch /". expand("")."/"
        elseif a:1 == 6
            execute "syntax match StatusLine /". expand("")."/"
        elseif a:1 == 7
            execute "syntax match VisualNOS /". expand("")."/"
        elseif a:1 == 8
            execute "syntax match Folded /". expand("")."/"
        elseif a:1 == -1
            match none
        else
            echo "argument can only be blank, or 1 through 8"
        endif
    elseif a:0 == 2
        if a:1 == 1 
            execute "syntax match DiffDelete /". a:2 ."/"
        elseif a:1 == 2
            execute "syntax match DiffText /". a:2 ."/"
        elseif a:1 == 3
            execute "syntax match Error /". a:2 ."/"
        elseif a:1 == 4
            execute "syntax match WildMenu /". a:2 ."/"
        elseif a:1 == 5
            execute "syntax match IncSearch /". a:2 ."/"
        elseif a:1 == 6
            execute "syntax match StatusLine /". a:2 ."/"
        elseif a:1 == 7
            execute "syntax match VisualNOS /". a:2 ."/"
        elseif a:1 == 8
            execute "syntax match Folded /". a:2 ."/"
        else
            echo "argument can only be blank, or 1 through 8"
        endif
    endif
endfunction

command! -nargs=* Xhi :call Xh()




Hosted by www.Geocities.ws

1