"Returns the visually selected text function! vebugger#util#get_visual_selection() "Shamefully stolen from http://stackoverflow.com/a/6271254/794380 " Why is this not a built-in Vim script function?! let [lnum1, col1] = getpos("'<")[1:2] let [lnum2, col2] = getpos("'>")[1:2] let lines = getline(lnum1, lnum2) let lines[-1] = lines[-1][: col2 - (&selection == 'inclusive' ? 1 : 2)] let lines[0] = lines[0][col1 - 1:] return join(lines, "\n") endfunction "Prompts the user with a filtered list of process, and returns the process id "the user selects function! vebugger#util#selectProcessOfFile(ofFile) let l:fileName=fnamemodify(a:ofFile,':t') if has('win32') "Get the process data in CSV format let l:resultLines=split(vimproc#system('tasklist /FO csv /FI "IMAGENAME eq '.l:fileName.'"'),'\r\n\|\n\|\r') if l:resultLines[0]=~'\V\^INFO:' throw 'No matching process found' endif "Parse(sort of) the CSV: let l:resultLinesParsed=map(l:resultLines,'eval("[".v:val."]")') let l:resultLinesParsed[0][2]='Session' "Format for output let l:linesForPrinting=map(copy(l:resultLinesParsed),'v:val[1]."\t".v:val[2]."\t\t".v:val[0]') else let l:resultLines=split(vimproc#system('ps -o pid,user,comm,start,state,tt -C '.fnameescape(l:fileName)),'\r\n\|\n\|\r') let l:linesForPrinting=copy(l:resultLines) endif if len(l:linesForPrinting)<=1 throw 'No matching process found' endif if &lines