home *** CD-ROM | disk | FTP | other *** search
/ vim.ftp.fu-berlin.de / 2015-02-03.vim.ftp.fu-berlin.de.tar / vim.ftp.fu-berlin.de / mac / vim55rt.sit / runtime / macros / file_select.vim < prev    next >
Encoding:
Text File  |  1999-09-25  |  24.7 KB  |  466 lines  |  [TEXT/VIM!]

  1. " vm: set com=b\:\" tw=79 fo=croq2 :
  2. "
  3. "        File manager macros for Vim 5    (UNIX only)
  4. "
  5. "     Author:  Ra'ul Segura Acevedo <raul@turing.iquimica.unam.mx>
  6. " Last modified:  971219  (1997 Dec 19)
  7. "    Suggestion:  Add the command "so filename" in your ~/.vimrc
  8. "          (where filename is the name of this file).
  9. "
  10. "
  11. " To get the last version send a mail to <raul@turing.iquimica.unam.mx> with
  12. " SUBJECT: "send file manager macros 5 uuencoded".
  13. " or if you are sure your mail system doesn't split long lines use:
  14. " SUBJECT: "send file manager macros 5".
  15. " To get the version for vim4.5 and vim 4.6 use:
  16. " SUBJECT: "send file manager macros uuencoded".
  17. " SUBJECT: "send file manager macros".
  18. "
  19. " User commands from any buffer:
  20. " _ls    loads vim's current directory.
  21. " _LS    loads the current file's directory. (it doesn't work on a [No File]).
  22. "
  23. " or 'edit' the directory ("vim /tmp", or from vim with ":e .", ":sp ~/bin",
  24. "
  25. " Magic Keys:
  26. "
  27. " In normal mode:
  28. "
  29. "   _H        Show keys/functions table.
  30. "   <Return>    On a file entry.  Loads the file/directory.
  31. "   <Return>    On a line starting with ":" executes the line as a :-command.
  32. "   <Return>    On any other line.  Executes the 'listing command' (such as
  33. "        ":r!/bin/ls -lLa /home/user", displayed on line 1)
  34. "   <C-N>    Moves the cursor to the next file entry.
  35. "        ([count]<C-N> also works:  9<C-N>)
  36. "   <C-P>    Moves the cursor to the previous file entry.
  37. "        ([count]<C-P> also works:  9<C-P>)
  38. "   o        Same as <Return> but it splits the window first.
  39. "   U        Loads the parent directory. (The current buffer is not deleted).
  40. "   R        Refresh (executes the 'listing command').
  41. "   Q        Quit.
  42. "
  43. "   %        (Un)Tag a file entry.  It can be used alone on the current line,
  44. "        or from the visual to toggle the tag of the highlighted lines.
  45. "        The easiest way to untag all the files is pressing "R" (refresh)
  46. "
  47. " The next commands create a new window which prompts the user to execute a
  48. " command on the "selected files".  Where "selected files" means:
  49. "    1) The highlighted files under visual mode.
  50. "    2) If you are not in visual mode, the files  tagged with % (a % is
  51. "       showed at the beginning of the lines)
  52. "    3) If there are no tagged files, the file entry in the current line
  53. "    4) If there is no file entry in the current line either, then the
  54. "       macros' working directory.
  55. " To execute the command type "done", if no messages (errors) are returned then
  56. " the window is deleted, otherwise the window displays those messages and "u"
  57. " (undo) can be used to get back the previous contents of the buffer.
  58. " "Q" can be used to quit without executing the command.
  59. "
  60. "   _CP        Copy the file(s) to another place.
  61. "   _MV        Move the file(s) to another place.
  62. "   _LN        Link the file(s) to another place.
  63. "   _SLN    (Symbolic) Link the file(s) to another place.
  64. "   _MK        Make directories (the given files are used as a template)
  65. "   _CM        Change the file(s) mode (chmod).
  66. "   _CO        Change the file(s) owner (chown).
  67. "   _CG        Change the file(s) group (chgrp).
  68. "   _RM        Remove the file(s) (directories have to be empty)
  69. "   _RF        Remove (force) the file(s) (rm -rf is used, directories are
  70. "        removed recursively).  BE CAREFUL with this one.
  71. "   _SH        This macro just list the given files/directories and the
  72. "        macros' working directory, so you can use those names with any
  73. "        command you wish, say tar, gzip, or whatever.
  74. "
  75. " In insert mode:
  76. "   <Return>    Exits insert mode and does the same as <Return> in normal mode.
  77. "   <Tab>    Expands filenames.
  78. "        (These commands are useful to edit the listing-command.)
  79. "
  80. " In the GUI version:
  81. "   <2-LeftMouse>    Same as "o" (Split window and open file/dir)
  82. "   <C-LeftMouse>    Same as "%" (Togle Tag)
  83. "   <C-LeftDrag>    Toggle-Tag files as the mouse pass over them.
  84. " All the commands can be executed from the "LS" menu.
  85. "
  86. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  87.  
  88. " Syntax highlighting
  89. "
  90. " In a directory window the filenames are highlighted depending on the type of
  91. " file.  There are two sets of colors, one similar to linux's ls-color, and
  92. " other to the default ls-color.
  93. "
  94. " To always use the linux set, uncomment the following line:
  95. " let ls_syntax_linux=1
  96. " To always use the normal set, uncomment the following line:
  97. " let ls_syntax_linux=0
  98. " If ls_syntax_linux is not set the linux colors are used if and only if there
  99. " is an enviroment variable $OSTYPE set to "linux"
  100. "
  101. " Type            Linux Set    Normal Set
  102. "
  103. " Directory        blue        green
  104. " Symbolic link        cyan        cyan
  105. " Named pipe (FIFO)    brown        red
  106. " Socket        magenta        yellow
  107. " Block/Char. Device    yellow        white on a blue background
  108. " Executable        green        magenta
  109. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  110.  
  111. " The internal macros start with "__" and end with "-".
  112. "
  113. " __CQ-  quotes all the shell metacharacters (see comment just above the macro
  114. "     to see exactely which chars. are quoted) in the given lines so each
  115. "     line can be seen as a single pathname. (normally used just in the
  116. "     current line: 1__CQ-) the line must start with a space.  cursor: ends
  117. "     in col. 1.  pattern: :-search (& therefore last-search too), replace.
  118. "
  119. " __LS-  the given lines have pathnames, it strips the first occurrence of
  120. "     the following "words": (anything might be before or after them)
  121. "     //something//../ ->    /   (// means at least 1 / in a row)
  122. "     //../          ->    /   (//../ at the beginning of the pathname)
  123. "                    (// means at least 1 / in a row)
  124. "     //./          ->    /   (// means at least 1 / in a row)
  125. "     //          ->    /   (// means at least 2 / in a row)
  126. "     cursor: same line, but might end on column 1.    pattern: all.
  127. "
  128. " __L1-  Adds the 'listing command' (:r!/bin/ls -lLa <dir>) in line 1, which is
  129. "     always needed to get the (macro's) working directory. <dir> is quoted
  130. "     with __CQ-.  cursor: line 1, just before the dir. name.  register:-,"
  131. "
  132. " __L1C- checks if the first line is a :-command, calls __L1- if not.    Calls
  133. "     __LS- to strip the dir. name.    (an aux. map is used: __L-)
  134. "     cursor: line 1, might end in col 1.  register: -," (iff _L1- called).
  135. "     pattern: search patterns changed.
  136. "
  137. " __LC-  this macro is executed on a line which starts with ":", assuming it
  138. "     is a :-command to list files, the line is *copied* (to ensure there
  139. "     are at least 2 lines in the buf.) to the first line, a message is
  140. "     printed in the second line and all the other lines are removed.  Then
  141. "     the :-command is executed.    Finally it adds a / to the directories
  142. "     names, inserts 2 spaces before every file entry, and :set's nomod.
  143. "     cursor: last file entry (last line).    pattern: all.    pattern: all.
  144. "     register: .(msg), 0 (listing com.), 1 and " (previous buf. contents)
  145. "
  146. " __LBD- It creates a normal-command to display the file whose name appears in
  147. "     the current line (it is inserted in the command line later using ^R-,
  148. "     this way special vim-char. wont be interpreted as commands, say ^M)
  149. "     and deletes the current buf.    register: .
  150. "
  151. " __LK-  It creates a normal-command to undo the changes and display the file
  152. "     whose name appears in the current line (it is inserted in the command
  153. "     line later using ^R-, this way special vim-char. wont be interpreted
  154. "     as commands, say ^M) The listing buffer is kept.    register: .
  155. "
  156. " __LF-  called when <CR> is typed in a line which looks like a file entry, it
  157. "     expects the filename in register 0 (yank), the listing command on line
  158. "     1 (to get the dir. name), and a macro __LFP- mapped to either __LBD-
  159. "     or __LK- depending on whether the current buf. is going to be deleted
  160. "     or kept.  First, it removes everything but the dirname from line 1, It
  161. "     quotes the filename, adds the dir. if needed, __LS-strips it, loads
  162. "     that file by executing the command generated by __LFP- and finally
  163. "     shows the file info (:f), note that it explicitly jumps to line 1 to
  164. "     avoid "Press return" msgs.    cursor: col 1. (not sure), line 1.
  165. "     register: ", - (loading command).    patterns: all.
  166. "
  167. " __LN-  looks forward for a filename, if the cursor is at the start of a line
  168. "     with a file entry, then this macro moves the cursor to the beginning
  169. "     of the filename, (note that 3E2l must not be replaced with 4W or the
  170. "     macro will get confused with filenames starting with spaces/tabs)
  171. "     cursor: beginning of a filename (hopefully).    pattern: last search.
  172. "
  173. " __LWh- sets [Wh]ich action will be done by the macro __LD- depending on
  174. "     whether the current line looks like a file entry, a :-command, or
  175. "     none (when "none", the listing command is executed) finally calls
  176. "     __LD-.    patterns: all.    registers: depend on __LD-
  177. "
  178. " _H     Open a new window to display the key/function table.
  179. "
  180. " %     it toggles the tag (leading % char.) of the selected lines (default
  181. "     just the current, but it can be used from the visual)
  182. "     cursor: below the end of the selected area.    patterns: all.
  183. "
  184. " __LSC- (shell command) marks the current line (y) so the cursor goes back to
  185. "     there just before leave the buffer.    Puts the current line, and all
  186. "     the tagged ones in register l, the listing command is yanked, then
  187. "     :splits another window, (named: /Command(from_%):_<command name from
  188. "     macro __L_C->, if it already exists then its previous contents are
  189. "     kept), pastes the register l as the first paragraph and the second
  190. "     paragraph starts with a white space followed by the macros' working
  191. "     directory (gotten from the listing command) this line is marked (also
  192. "     "y", but remember we R in a different buffer now) and yanked (without
  193. "     the trailing NL) and finally the macro __CI- is called.  After that
  194. "     the first paragraph has quoted full pathnames with a leading white
  195. "     space, the second paragraph is not modified by __CI-, instructions are
  196. "     inserted automatically at the end of the buffer when it is created.
  197. "     cursor: first line, column 1, of a new window.    pattern: all.
  198. "     registers: ", l, 0, -, ., %
  199. "
  200. " __LCM- This macroS (normal & visual) are called from _CP, _MV, etc. to map
  201. "     __L_C- to the name of the command to be displayed in the status line
  202. "     and to define __LG- to either ":g/^%/" or ":'<,'>g/^[ %]/" to be used
  203. "     later in __LSC- to pick the tagged files or the files in the visual
  204. "     respectively.
  205. "
  206. " _CP, _MV, _LN, _SLN
  207. "     these macros first call __LCM- and __LSC to create a new window which
  208. "     prompts the user to copy/move/link/symbolic-link the given files
  209. "     (files in the visual, if not called from the visual (normal then) the
  210. "     tagged files, if there are none, the file on the current line, if it
  211. "     doesn't list a file then the (macros') working directory:) to the
  212. "     (macro's) working directory.  The cursor is left at the end of working
  213. "     directory name so it can be easily edited.    registers: l, ", 1, -.
  214. "     patterns: all.
  215. "
  216. " _RF     call __LSC to create a new window which prompts the user to delete
  217. "     the given files, and directories.    rm -rf is used!!
  218. "     directories are removed recursively.
  219. " _RM     same as _RF but it uses rm on files and rmdir on directories, (so
  220. "     directories must be empty)
  221. "
  222. " _MK     call __LSC to create a new window which prompts the user to create
  223. "     directories (the given files are used as a template)
  224. "
  225. " _CM (_CHM), _CG (_CHG), _CO (_CHO)
  226. "     these macros call __LSC to create a new window which prompts the user
  227. "     to chmod/chgrp/chown the given files. The cursor is left between the
  228. "     command and the first filename where an argument must be inserted.
  229. "
  230. " _SH     call __LSC to create a new window which shows the given files first,
  231. "     then the given directories (separated with an empty line) and finally
  232. "     the macros' working directory, so the user can pass those names to any
  233. "     command. (":.g/./" can be used to check if there are directories, and
  234. "     ":1g/./" to check if there are files) cursor: on the directories
  235. "     paragraph (or on the second empty line if there were no directories)
  236. "
  237. " <CR>     in insert-mode goes to normal mode and then execute the normal-mode's
  238. "     macro <CR>.
  239. " <Tab>  in insert mode, expands file names.
  240. "
  241. " <CR>     normal-mode set __LFP- to __LBD-, and then calls __LWh- which means
  242. "     that a new file/directory is going to be loaded and the current
  243. "     buffer will be removed.
  244. "    on a line with a file entry, that file (or directory) is loaded.
  245. "    on a line starting with : that line is executed as a :-command.
  246. "    on any other line the 'listing command' (normally on line 1) is executed.
  247. "
  248. " __L:- Shows in the command mode line the contents of the file from the cursor
  249. "    position to the end of the line.  Used by <C-N>, <C-P> and BufEnter to
  250. "    remove the garbage in that line showing the current filename entry.
  251. "
  252. " <C-N>    moves the cursor to the next line, and then calls __LN- from the
  253. "    beginning of the line to jump to the next file name.    calls __L:-.
  254. "    [count]<C-N> works too.
  255. "
  256. " <C-P>    moves the cursor to the previous line, and then calls __LN- from the
  257. "    beginning of the line to jump to the next file name.    calls __L:-.
  258. "    [count]<C-P> works too.
  259. "
  260. " o    set __LFP- to __LK- and then calls __LWh-, so works like <CR> but
  261. "    doesn't destroy the current buffer.    It splits the window too.
  262. "
  263. " U    loads parent directory.    (current buffer is not deleted) it first
  264. "    checks for the listing command and deletes everything after the last /
  265. "    adds a ../ at the end of the line, strips the directory's name, and
  266. "    executes the listing command, finally the buffer's name is set
  267. "    accordingly to the directory's.    and the cursor is left in the first
  268. "    file entry.
  269. "
  270. " Q    quit
  271. "
  272. " R    refresh.  before the refresh: if the current line has a file entry then
  273. "    just the filename is used, in any case, the search-metacharacters in
  274. "    the line are quoted, the line is yanked in register "l" (lower L) and
  275. "    the changes undone, after the refresh the cursor is in the last line,
  276. "    it is then moved to the last column where a backward search starts
  277. "    looking for the former current line or the "^:" which always exists in
  278. "    line 1, finally, a dummy ":" command is executed to clean the last
  279. "    message.
  280. "
  281. " __+-    refresh.  call R and then sets mark `.    Called by the /Command*'s
  282. "    macro "done" (m`__+-``).  This is the only internal macro without a L/C
  283. "    in it's name.    That's because when "__+-" is interpreted the cursor
  284. "    may or may not be in the listing window, so, it has to be harmless in a
  285. "    "normal" buffer.
  286. "
  287. " The buffer's refresh is automatically done when it is empty.
  288. " The autocommands "." also :set magic tw=0 wm=0 noai nosi nocin nolisp fo=
  289. "
  290. "
  291. " in the buffers /Command*
  292. " __CJ-     joins the lines in a paragraph without adding or removing any space.
  293. "     and :set nomod.    cursor: first non-blank
  294. " __CJD- same as __CJ- but also removes the next line.    cursor: last column.
  295. " __CJj- same as __CJ- but also joins    the next line.    cursor: last column.
  296. "
  297. " done     filters the buffer through $SHELL, if no messages (errors) are
  298. "     returned then the window is deleted, otherwise the window displays
  299. "     those messages and "u" (undo) can be used to get back the previous
  300. "     contents of the buffer.  Finally, "m`__+-``" is executed, it is
  301. "     harmless in a normal buffer, but in the listing window it refreshes
  302. "     the listing.    note that in a normal buffer, if the cursor is in the
  303. "     last line then m`__+-`` moves the cursor to the beginning of the line.
  304. "
  305. " Q     quit.
  306. " <Tab>  insert-mode expand filenames.
  307. " <CR>     insert-mode exits insert-mode.
  308. "
  309. " __CB-  prints a banner at the end of the buffer giving instructions.
  310. "     the cursor is left at the end of the buffer.
  311. "
  312. " __CI-  (called from __LSC-) it gets what was the listing buffer's current
  313. "     line in line 1, the tagged lines (if any) from line 2 on, the macros'
  314. "     working directory in the next paragraph (marked y) and in registers 0
  315. "     and ", and the cursor in line 1, then checks line 2, if there are
  316. "     tagged lines then the first line is removed, after that, if line 1
  317. "     doesn't look like a file entry then it is replaced with a dummy entry
  318. "     to the "./" file so the first paragraph has always a list of file
  319. "     entries which is then marked with the visual to execute 4 global
  320. "     commands on it, 1) remove everything but the filename, 2)quote (__CQ-)
  321. "     those filenames, 3) add the directory name if needed, or some blanks
  322. "     otherwise (from the yank buffer) and 4) strips (__LS-) the pathnames.
  323. "     patterns: all.    registers: -, 1, ".    cursor: in the first paragraph.
  324. "
  325. " The autocomands for /Command* also :set tw=0 wm=0 noai nosi nocin nolisp fo=
  326. " and insert "instructions" in the last line if the last line is empty.
  327. "
  328. " The /File/manager/keys windows has just 2 maps:
  329. " Q    delete the window.
  330. " R    refresh: clears the window and inserts the key/function table.
  331. " and :set tw=0 wm=0 noai nosi nocin nolisp fo=
  332. "
  333. """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
  334.  
  335. aug LS
  336. au!
  337. " quote this groups of chars: <CR> <space>!"#$&'()* <Tab> :;<=>? [\]^ ` {|}~
  338. au BufEnter .,/Command* no__CQ- :s/[ -*    :-?[-^`{-~]/\\&/g<CR>
  339. au BufEnter .,/Command* no__LS- :g-\(/\+[^/]*\)\=/\+\.\./\<BAR>/\+\.\=/-s--/-<CR>
  340. au BufEnter . nm__L1- O:r!/bin/ls -la /<Esc>hd0"=expand("%:p")<CR>p1__CQ-Plx
  341. au BufEnter . nm__L1C- :nm__L- 1G<BAR>1v-^:-nm__L- __L1-<CR>__L-1__LS-
  342. au BufEnter . no__LC- yy1GPA<NL>Type _H for a list of commands, see <sfile>:p for details.<Esc>jdG@0:g-^[ 0-9]*d-s-/*$-/<CR>:g/^[^:].*[0-9] \K..  \=[0-9]/s/^/  <CR>:se nomod<CR>
  343. au BufEnter . nn__LBD- Cu:e<C-V><C-R>-<Bar>bd#<Esc>
  344. au BufEnter . nn__LK- Cu:e<C-V><C-R>-<Esc>
  345. au BufEnter . nm__LF- 03xdEdt/$p,D0D"0p1__CQ-:.v-^. /-norm2l"-P0<CR>2x1__LS-0__LFP-y1G@":f<CR>1G
  346. au BufEnter . nn__LN- 0/[0-9] \K..  \=[0-9]<CR>3E2l
  347. au BufEnter . nm__LWh- :nm__LD- __LC-1G__LN-<Bar>.g/^\([ %] [ 0-9]*l.*\) -> .*/s//\1<CR>:.g/^[ %]/nm__LD- __LF-<BAR>norm __LN-hy$<CR>:.g/^:/t0<CR>__L1C-__LD-
  348. au BufEnter . nm_H :5sp!/File/manager/keys<CR>R<C-W>p|map<F1> _H
  349.  
  350. au BufEnter . nm% v%|vn% :g/^%/s//x<CR>:'<,'>g/^ /s//%<CR>:'<,'>g/^x/s// <CR>:se nomod<CR>:"toggle tag"<CR>`>j
  351. au BufEnter . nm__LSC- myylpX:.g/^\([ %] [ 0-9]*l.*\) -> .*/s//\1<CR>"lyyuylpX__L1C-yy__LG-<BS> [ 0-9]*l/s/\(.*\) -> .*/\1/<CR>__LG-y L<CR>u`y:5new/Command/__L_C-<BAR>cu <C-V>__L_C-<CR>1G"0Pf!Et/d0yl3Pmy$pT/DyyP0y$D"lP__CI-1G0
  352.  
  353. au BufEnter . vn__LCM- :g/^[ %]/<Home>nn__LG- :<CR>:cno__L_C- |            nn__LCM- :nn__LG- :g/^%/<BAR>cno__L_C- 
  354. au BufEnter . map_CP __LCM-cp<CR>__LSC-icp<Esc>__CJj-
  355. au BufEnter . map_MV __LCM-mv<CR>__LSC-imv<Esc>__CJj-
  356. au BufEnter . map_LN __LCM-ln<CR>__LSC-iln<Esc>__CJj-
  357. au BufEnter . map_SLN __LCM-ln-s<CR>__LSC-iln -s<Esc>__CJj-
  358. au BufEnter . map_RF __LCM-rm-rf<CR>__LSC-irm -rf<Esc>__CJD-
  359. au BufEnter . map_RM __LCM-rm<CR>__LSC-'yD:1,-2g-/$-m'y-<CR>:.g--norm {jirmdir<C-V><ESC>__CJ-<CR>:1g/./norm 0irm<C-V><Esc>__CJ-<CR>$
  360. au BufEnter . map_MK __LCM-mk<CR>__LSC-imkdir<Esc>__CJD-T/
  361. au BufEnter . map_CM __LCM-cm<CR>__LSC-ichmod <Esc>__CJD-0e2l|map_CHM _CH
  362. au BufEnter . map_CG __LCM-cg<CR>__LSC-ichgrp <Esc>__CJD-0e2l|map_CHG _CG
  363. au BufEnter . map_CO __LCM-co<CR>__LSC-ichown <Esc>__CJD-0e2l|map_CHO _CO
  364. au BufEnter . map_SH __LCM-sh<CR>__LSC-}yyp:1,-2g-/$-m'y-2<CR>0
  365.  
  366. au BufEnter . im<CR> <Esc><CR>|ino<TAB> <C-X><C-F>
  367. au BufEnter . nm<CR> :nm__LFP- __LBD-<CR>__LWh-|nm o :sp<Bar>nm__LFP- __LK-<CR>__LWh-
  368. au BufEnter . nn__L:- y$:"<C-R>""<CR>|nm<C-N> +__LN-__L:-|nm<C-P> -__LN-__L:-
  369. au BufEnter . nm U __L1C-A../<Esc>2hdT/1__LS-__LC-1G0f!Ef/y$__LN-:f <C-R>"<CR>
  370. au BufEnter . nn Q :bd!<CR>
  371. au BufEnter . nm R :.g-^[% ]-norm__LN-d0<CR>__magic0"ly$u__L1C-__LC-$?^:\<Bar> <C-R>l$<CR>l:"refresh"<CR>
  372. au BufEnter . se magic tw=0 wm=0 noai nosi nocin nolisp fo=
  373. au BufEnter . nm__+- Rm`|nn__L- m`|nn__LFP- m`|nn__LG- m`
  374. " [R]efresh only iff the buffer is empty
  375. au BufEnter . let b:ls_done=1
  376. au BufEnter . nn__LD- m`|1v/./nm__LD- __L1C-__LC-1G__LN-
  377. au BufEnter . norm__LD-__L:-
  378.  
  379. au BufLeave . unm__CQ-|unm__LS-|unm__L1-|unm__L1C-|unm__LC-|unm__LBD-|        unm__LK-|unm__LF-|unm__LN-|unm__LWh-|unm__LD-|unm__L-|unm__LFP-|unm_H|        iun<CR>|iun<Tab>|nun<CR>|nun__L:-|nun<C-N>|nun<C-P>|nun o|nun U|nun Q|        nun R|nun__+-|unm_MK|unm_CP|unm_MV|unm_LN|unm_SLN|unm_RF|unm_RM|unm<F1>|    unm__LSC-|unm%|unm_CHM|unm_CHG|unm_CHO|unm_SH|unm__LCM-|unm__LG-|unm_CM|    unm_CG|unm_CO
  380. au BufLeave . unlet b:ls_done
  381.  
  382. map_ls :sp %:p:h<CR>
  383. map_LS _ls
  384.  
  385. au BufEnter /File/manager/keys nn Q :bd!<CR>|nn R :%d<CR>iRa'ul Segura Acevedo <raul@hplara.iquimica.unam.mx><CR>#CR> open    <Bar> #C-N> next     <Bar> _MV    move   <Bar> _LN  link    <Bar> _CO chown<CR>o    split&open    <Bar> #C-P> previous <Bar> _CP    copy   <Bar> _SLN sym. link    <Bar> _CM chmod<CR>U    up dir.    <Bar> %    tag file <Bar> _RM    delete <Bar> _MK  make dir. <Bar> _CG chgrp<CR>R    refresh    <Bar> Q    *QUIT*   <Bar> _RF    rm -rf <Bar> _SH  shell free style<CR>Insert mode: #CR> enter  #Tab> expand. GUI: #2-clic> split&enter  <C-Clic> tag<Esc>:%s/#/</g<Bar>se nomod<CR>Gz-
  386. au BufLeave /File/manager/keys nun Q|nun R
  387.  
  388. au BufEnter /Command*    nn__CJ- vap:j!<CR>:se nomod<CR>
  389. au BufEnter /Command*    nn__CJD- vap:j!<CR>JD:se nomod<CR>
  390. au BufEnter /Command*    nn__CJj- vapj:j!<CR>:se nomod<CR>$
  391. au BufEnter /Command*    nm done :%!$SHELL<CR>:g/./"<CR>y$:if@"==""<Bar>norm Qm`__+-``<CR>end  "Command Output"<CR>|nn Q :bd!<CR>
  392. au BufEnter /Command*    ino<TAB> <C-X><C-F>|ino<CR> <Esc>
  393. au BufEnter /Command*    nn __CB- Gi# Normal mode: Type "done" to execute the command, "Q" to quit.<NL># Insert mode: Tab to expand filenames, Return go to Normal mode.<Esc><<<<
  394.  
  395. au BufEnter /Command*    nm__CI- :2g/./1d<CR>:1v-^[% ]-s-.*-6 Nul 6 6 ./<CR>vapk:g/[0-9] \K..  \=[0-9]/norm /<C-V><CR>3Eld0<CR>gv__CQ-:*s/..//<CR>:.g-^/-norm `y0yt/``<CR>gv:g/^/norm "0P<CR>gv__LS-
  396. au BufEnter /Command*,/File/manager/keys se tw=0 wm=0 noai nosi nocin nolisp nolist isk=@,-,<,>,48-97 fo=
  397. au BufEnter /Command*    nn__L- m`|$v/./nm__L- __CB-
  398. au BufEnter /Command*    norm__L-
  399. au BufLeave /Command*    unm__CQ-|unm__LS-|unm__CI-|unm__CB-|unm__CJ-|unm__CJj-|        unm__CJD-|unm__L-|iu<Tab>|iu<CR>|unm Q|unm done
  400.  
  401. " the next macro comes from my set of emacs-like incremental search macros
  402. nn__magic    :.g/[[$^.*~\\/?]/s//\\&/g<CR>
  403.  
  404. "    GUI stuff
  405. if has("gui")
  406.   au BufEnter . nm<2-LeftMouse> :nm__L- <C-V><CR><CR>:.v-/$-nm__L- o<CR>__L-|    nm<C-LeftMouse> <LeftMouse>%|vm<C-LeftMouse> %|nm<C-LeftDrag> <RightDrag>%
  407.  
  408.   au BufEnter . ime LS.Expand\ name <Tab>|    ime LS.Next\ name <C-N>|    nme LS.Next\ name <C-N>|    ime LS.Prev\.\ name <C-P>|    nme LS.Prev\.\ name <C-P>|    nme LS.Open <CR>|    ime LS.Open <CR>|    nme LS.Split&Open o|    nme LS.Up\ dir U|    nme LS.Refresh R|    nme LS.Close Q|    men LS.\  \ |    men LS.Toggle\ tag %|    men LS.Tag\ all :g/^ /s//%<CR>:se nomod<CR>:"Tag all"<CR>``|    men LS.UnTag\ all :g/^%/s// <CR>:se nomod<CR>:"Untag all"<CR>``|    men LS.Move _MV|    men LS.Copy _CP|    men LS.Delete _RM|    men LS.Make\ dir _MK|    men LS.Link _LN|    men LS.Sym\.\ link _SLN|    men LS.ChOwn _CO|    men LS.ChMod _CM|    men LS.ChGrp _CG|    men LS.Shell _SH|men LS.\ \  \ |men LS.DelTree _RF
  409.  
  410.   au BufLeave . unm<C-LeftMouse>|nun<2-LeftMouse>|nun<C-LeftDrag>|unme LS|     nme LS.File's\ dir _LS|nme LS.Vim's\ dir _ls|iunme LS
  411.   nme LS.File's\ dir    _LS
  412.   nme LS.Vim's\ dir    _ls
  413.  
  414.   au BufEnter /Command* nme Command.Close Q|nme Command.Execute done
  415.   if has("gui_athena")
  416.     au BufEnter /Command* nme Command.sh mm|unme Command.sh
  417.     au BufLeave /Command* nme Command.sh :sp/Command/sh<Bar>se nomod<CR>|unme Command.Close|unme Command.Execute
  418.   el
  419.     au BufLeave /Command* unme Command
  420.   en
  421. endif
  422. au BufEnter * if isdirectory(expand("%"))&&!exists("b:ls_done")|do BufEnter .|en
  423. au BufLeave * if exists("b:ls_done")|do BufLeave .|en
  424.  
  425. if has("syntax")
  426.   au BufEnter . if exists("syntax_on") && !has("syntax_items")
  427.   au BufEnter . sy match LsAny    ".*" contains=LsBody
  428.   au BufEnter . sy match LsExe    "^. \S*x.*" contains=LsBody
  429.   au BufEnter . sy match LsDir    "^. d.*" contains=LsBody
  430.   au BufEnter . sy match LsSln    "^. l.* -> "he=e-4 contains=LsBody
  431.   au BufEnter . sy match LsFifo    "^. p.*" contains=LsBody
  432.   au BufEnter . sy match LsSpl    "^. [cb].*" contains=LsBody
  433.   au BufEnter . sy match LsSock    "^. s.*" contains=LsBody
  434.   au BufEnter . sy match LsBody    contained "^.*[0-9] \K\K\K [ 0-3][0-9] [ 0-9]\S* " contains=Tag
  435.   au BufEnter . sy match Tag    contained "^%.*[0-9] \K\K\K [ 0-3][0-9] [ 0-9]\S*"
  436.   au BufEnter . sy match Comment    "^Type _H.*"
  437.   au BufEnter . sy match Operator    "^:.*"
  438.   au BufEnter . en
  439.   au BufEnter /File/manager/keys sy    match    Tag    "[<_%]\S*\|\<.\>"
  440.   au BufEnter /File/manager/keys sy    match    Comment    "[IGN].\{-}:"
  441.   au BufEnter /Command*    sy    match    Comment    "^#.*" contains=Tag
  442.   au BufEnter /Command*    sy    keyword    Tag    contained done Q Tab Return
  443.   if !exists("did_ls_syntax_inits")
  444.     let did_ls_syntax_inits = 1
  445.     if !exists("ls_syntax_linux")
  446.       let ls_syntax_linux=$OSTYPE=="linux"
  447.     en
  448.     if ls_syntax_linux
  449.       hi LsDir    start=<Esc>[1,34m stop=<Esc>[m ctermfg=blue guifg=blue
  450.       hi LsSln    start=<Esc>[1,36m stop=<Esc>[m ctermfg=cyan guifg=cyan
  451.       hi LsFifo    start=<Esc>[33m stop=<Esc>[m ctermfg=brown guifg=#ffff60
  452.       hi LsSock    start=<Esc>[1,35m stop=<Esc>[m ctermfg=magenta guifg=Magenta
  453.       hi LsSpl    start=<Esc>[1,33m stop=<Esc>[m ctermfg=yellow guifg=#ffff60 gui=bold
  454.       hi LsExe    start=<Esc>[1,32m stop=<Esc>[m ctermfg=green guifg=green
  455.     el
  456.       hi LsDir    start=<Esc>[32m stop=<Esc>[m ctermfg=green guifg=green
  457.       hi LsSln    start=<Esc>[36m stop=<Esc>[m ctermfg=cyan guifg=cyan
  458.       hi LsFifo    start=<Esc>[31m stop=<Esc>[m ctermfg=red guifg=Red
  459.       hi LsSock    start=<Esc>[33m stop=<Esc>[m ctermfg=yellow guifg=#ffff60
  460.       hi LsSpl    start=<Esc>[44,37m stop=<Esc>[m ctermfg=white ctermbg=blue guifg=white guibg=blue
  461.       hi LsExe    start=<Esc>[35m stop=<Esc>[m ctermfg=magenta guifg=Magenta
  462.     en
  463.   let b:current_syntax = "ls"
  464. endif
  465. aug END
  466.