m (Save each line of a text in separated numbered files moved to Save each line in separate numbered files: Page moved by JohnBot to improve title) |
(Change to TipImported template + severe manual clean) |
||
Line 1: | Line 1: | ||
{{review}} |
{{review}} |
||
+ | {{TipImported |
||
− | {{Tip |
||
|id=1059 |
|id=1059 |
||
+ | |previous=1058 |
||
− | |title=Save each line of a text in separated numbered files |
||
+ | |next=1061 |
||
− | |created=November 25, 2005 |
+ | |created=November 25, 2005 |
|complexity=basic |
|complexity=basic |
||
− | |author=Walter |
+ | |author=Walter López |
|version=6.0 |
|version=6.0 |
||
|rating=5/2 |
|rating=5/2 |
||
⚫ | |||
− | |text= |
||
− | Create this function |
+ | Create this function |
+ | <pre> |
||
⚫ | |||
⚫ | |||
⚫ | |||
+ | </pre> |
||
⚫ | |||
+ | <pre> |
||
⚫ | |||
+ | </pre> |
||
⚫ | |||
+ | <pre> |
||
⚫ | |||
⚫ | |||
− | |||
⚫ | |||
⚫ | |||
⚫ | |||
− | |||
+ | </pre> |
||
⚫ | |||
− | |||
− | |||
− | |||
⚫ | |||
− | |||
− | |||
− | |||
⚫ | |||
− | |||
− | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
− | |||
⚫ | |||
− | |||
− | |||
each containing a single line. |
each containing a single line. |
||
⚫ | |||
− | == |
+ | ==Comments== |
⚫ | |||
− | wow. just what we wanted |
||
+ | <pre> |
||
− | Dingo |
||
⚫ | |||
− | , November 25, 2005 23:39 |
||
+ | </pre> |
||
− | ---- |
||
⚫ | |||
− | |||
⚫ | |||
to get the same sort of effect. |
to get the same sort of effect. |
||
⚫ | |||
− | vim.tip [at] the chases {dot} com |
||
− | , November 26, 2005 5:55 |
||
− | ---- |
||
− | :g/^/exe ".w ".line(".").".txt" |
||
+ | <pre> |
||
⚫ | |||
− | :g/^/ |
+ | :g/^/ # for very line |
− | exe |
+ | exe # Execute the following string as an ex command ie : |
− | .w |
+ | .w # . means current line so .w means write current line |
− | line(".") |
+ | line(".") # returns current line number |
− | The string generated (for first line is) is |
+ | The string generated (for first line is) is |
:g/^/exe ".w 1.txt" |
:g/^/exe ".w 1.txt" |
||
+ | </pre> |
||
− | zzapper |
||
− | , November 28, 2005 9:15 |
||
− | ---- |
||
− | Great, without the function is better to do. Thanks!! |
||
− | |||
− | wjlc--AT--internet.com.uy |
||
− | , November 30, 2005 11:01 |
||
− | ---- |
||
− | vim is better than gmacs |
||
− | |||
− | parth007--AT--yahoo.com |
||
− | , December 2, 2005 22:38 |
||
---- |
---- |
||
− | <!-- parsed by vimtips.py in 0.576481 seconds--> |
Revision as of 10:15, 20 December 2007
Tip 1059 Printable Monobook Previous Next
created November 25, 2005 · complexity basic · author Walter López · version 6.0
Create this function
function! SaveLines() execute line(".") . "w " . line(".") . ".xml" endf
And call it
%call SaveLines()
The generated files are:
1.xml 2.xml ...
each containing a single line.
Comments
No need for a function. You can just use
:g/^/exe ".w ".line(".").".txt"
to get the same sort of effect.
Explanation:
:g/^/ # for very line exe # Execute the following string as an ex command ie : .w # . means current line so .w means write current line line(".") # returns current line number The string generated (for first line is) is :g/^/exe ".w 1.txt"