" A few macros that make up a nice file selector.  In case the command-line
" filename completion isn't enough.
"
"Usage:
"
"Type `_ls' to start it up, then use the following commands:
"
"   F - reload directory contents (useful after modifying top line
"       manually)
"   H - toggle hidden files
"   P - get parent directory
"   Q - quit
"
"   E - (when on a line listing a directory) enter this directory
"<CR> - (when on a line listing a file) start editing this file
"
"The macro itself (put it in your .vimrc):
"(NOTE: There's a space at the end of the second line (_;lsexec0) after the T)

:map _ls :sp ~/fileselect<CR><C-W>_:set tw=0<CR>:%d<CR>i:r! ls -lF <ESC>:r! pwd<CR>kJA/<CR><ESC>_;lsexec0
:map _;lsexec0 :2,$d<CR>yy@"3G$T 

:au! BufLeave fileselect nunmap <CR>
:au  BufLeave fileselect nunmap    E
:au  BufLeave fileselect nunmap    F
:au  BufLeave fileselect nunmap    H
:au  BufLeave fileselect nunmap    P
:au  BufLeave fileselect nunmap    Q
:au  BufLeave fileselect nunmap    ;_H0
:au  BufLeave fileselect nunmap    ;_H1

:au! BufEnter fileselect nnoremap <CR> $T y$1G$pF d^i:e <ESC>:set nomodified<CR>yy@":bd! fileselect<CR><C-W>=
:au  BufEnter fileselect nmap    E $T y$1G$p_;lsexec0
:au  BufEnter fileselect nmap    F _;lsexec0
:au  BufEnter fileselect nmap    H ;_H0
:au  BufEnter fileselect nmap    P 1G$T/d$_;lsexec0
:au  BufEnter fileselect nmap    Q :q!<CR>

:au BufEnter fileselect nmap ;_H0 :0s/-lF/-alF/<CR>_;lsexec0:nmap H ;_H1<CR>
:au BufEnter fileselect nmap ;_H1 :0s/-alF/-lF/<CR>_;lsexec0:nmap H ;_H0<CR>
