Edd Barrett wrote:
> Hi,
>
> This might already be possible, please excuse me if it is.
>
> I love the editting features of vim, but find that navigating between
> open files is quite difficult.
>
> Ideally I think I would be quite confortable with a kate like
> interface for listing open files:
> http://www.kde.org/screenshots/images/3.1/fullsize/2.png (screenshot)
>
> I got quite close by messing about with netrw in a vertical split, but
> the list pane did not:
>
> - Remain the same size
> - Show only one file to be open in the right hand pane. It would
> always split again for each newly selected file.
>
> Does anyone know how to do this?
>
> Would anyone find this useful?
>
> I have looked into using vim-part inside kate, but this is not
> supported for my UNIX distribution.
>

I haven't used Kate, but I'm using a combination of
- project (http://vim.sourceforge.net/scripts/script.php?script_id=69) to (re-)open files belonging to a custom file structure, - ProjectBrowse (http://vim.sourceforge.net/scripts/script.php?script_id=943) to open files in subdirectories and - most useful - - bufexplorer (http://vim.sourceforge.net/scripts/script.php?script_id=42) to navigate between files currently open in buffers.

I've set up those plugins to open in a vertical split at the left side (like in most IDEs). Each view can be toggled on/off via a function key (F2, F3, F4). If one view is already open, trying to open another one will close the former, so that they don't eat up all of my window space.

To achieve that, I've written mappings and VIM scripts like this (Attention! Incomplete code, just for illustration!):

function s:IsProjectWindowEnabled()
    if exists("g:proj_running")
        if( bufwinnr( bufname( g:proj_running ) ) != -1 )
            return 1
        endif
    endif
    return 0
endfunction

function s:ToggleProjectWindow()
" Project, TagList, JavaBrowser and BufExplorer vie for the same screen real estate; so
    " close other windows first.
    if( s:IsTagListEnabled() )
        call s:ToggleTagListWindow()
    endif
    if( s:IsJavaBrowserEnabled() )
        call s:ToggleJavaBrowserWindow()
    endif
    if( s:IsBufExplorerEnabled() )
        call s:ToggleBufExplorerWindow()
    endif

    " :Project has no toggle semantic itself, so we have to close the window
    " on our own.
    if( ! s:IsProjectWindowEnabled() )
        silent execute "Project"
    else
        silent execute "Project"
        silent execute "close"
    endif
endfunction

nmap <silent> <F2> :call <SID>ToggleProjectWindow()<CR>
imap <silent> <F2> <C-O>:call <SID>ToggleProjectWindow()<CR>

-- regards, ingo

/^-- Ingo Karkat -- /^-- /^-- /^-- /^-- /^-- /^-- http://ingo-karkat.de/ --

Reply via email to