JohnBeckett (talk | contribs) (Add todo for new tip) |
(Change <tt> to <code>, perhaps also minor tweak.) |
||
(7 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{TipNew |
||
− | {{TipProposed |
||
− | |id= |
+ | |id=1545 |
− | |previous= |
+ | |previous=1544 |
− | |next= |
+ | |next=1546 |
− | |created= |
+ | |created=2008 |
|complexity=basic |
|complexity=basic |
||
|author=Umu |
|author=Umu |
||
|version=7.0 |
|version=7.0 |
||
+ | |subpage=/200801 |
||
+ | |category1=Folding |
||
+ | |category2= |
||
}} |
}} |
||
+ | Given a huge file listing as text file, you can use this script to comfortably browse it. Use all fold commands of Vim to open/close parts of the directory tree, as used from standard file managers ( but even more flexible, including moving in fold structure, executing commands on folds ... ) |
||
− | Browse output of find, locate, tar -tf, ... in a file-browser like manner: |
||
+ | |||
+ | The more, on Unix-like systems you can pipe the output of tools like <code>find</code>, <code>locate</code>, <code>tar -t</code>, ... directly into Vim executing this script by using <code>-</code> as filename. |
||
+ | |||
+ | Examples: |
||
<pre> |
<pre> |
||
− | + | vim -u browser.vim arch-hurd-i386.files |
|
− | + | find . | vim -u browser.vim - |
|
− | + | locate nox | vim -u browser.vim - |
|
+ | tar -tzf boost.tar.gz | vim -u browser.vim - |
||
</pre> |
</pre> |
||
− | '''browser. |
+ | '''browser.vim''' |
<pre> |
<pre> |
||
set mouse=a |
set mouse=a |
||
Line 43: | Line 51: | ||
*Briefly explain purpose of tip and how to use (don't assume reader can quickly determine what idea is). |
*Briefly explain purpose of tip and how to use (don't assume reader can quickly determine what idea is). |
||
*Include something like "On Unix systems..." near top as hint for new readers. |
*Include something like "On Unix systems..." near top as hint for new readers. |
||
− | *Mention how the < |
+ | *Mention how the <code>-</code> makes Vim input from stdin. |
− | *Is <tt>browser.vimrc</tt> the best name (<tt>browser.vim</tt>?). |
||
---- |
---- |
||
− | [[Category:Folding]] |
Latest revision as of 06:31, 13 July 2012
Tip 1545 Printable Monobook Previous Next
created 2008 · complexity basic · author Umu · version 7.0
Given a huge file listing as text file, you can use this script to comfortably browse it. Use all fold commands of Vim to open/close parts of the directory tree, as used from standard file managers ( but even more flexible, including moving in fold structure, executing commands on folds ... )
The more, on Unix-like systems you can pipe the output of tools like find
, locate
, tar -t
, ... directly into Vim executing this script by using -
as filename.
Examples:
vim -u browser.vim arch-hurd-i386.files find . | vim -u browser.vim - locate nox | vim -u browser.vim - tar -tzf boost.tar.gz | vim -u browser.vim -
browser.vim
set mouse=a set foldminlines=1 foldcolumn=2 fillchars="+" foldlevel=0 set foldmethod=expr set foldexpr=FileBrowserFoldExpr() set foldtext=FileBrowserFoldText() function FileBrowserFoldExpr() let line=getline(v:lnum) let n=strlen(substitute(line,'[^/]*','','g')) if (line=~'^.*/$') return '>'.n elseif (strpart(getline(v:lnum+1),0,strlen(line)+1)==line.'/') return '>'.(n+1) endif return n endfunction function FileBrowserFoldText() return getline(v:foldstart) . ' ... [' . (v:foldend-v:foldstart+1) . ' lines]' endfunction
Comments[]
TO DO
- Briefly explain purpose of tip and how to use (don't assume reader can quickly determine what idea is).
- Include something like "On Unix systems..." near top as hint for new readers.
- Mention how the
-
makes Vim input from stdin.