Kann man im vi resp. vim irgendwie die geschrieben Zeichen (inkl. Leerzeichen) vom Editor zählen lassen?
Danke,
Julius
Zeichen zählen mit vi?
Zeichen zählen mit vi?
Last edited by julius on 25. Jun 2002 19:50, edited 1 time in total.
Re: Zeichen zählen mit vi?
<blockquote><pre><font size="1" face="">code:</font><hr><font face="Courier New" size="2">
==============================================================================
*12.4* Count words
Sometimes you have to write a text with a maximum number of words. Vim can
count the words for you.
When the whole file is what you want to count the words in, use this
command:
g CTRL-G
Do not type a space after the g, this is just used here to make the command
easy to read.
The output looks like this:
Col 1 of 0; Line 141 of 157; Word 748 of 774; Byte 4489 of 4976
You can see on which word you are (748), and the total number of words in the
file (774).
When the text is only part of a file, you could move to the start of the text,
type "g CTRL-G", move to the end of the text, type "g CTRL-G" again, and then
use your brain to compute the difference in the word position. That's a good
exercise, but there is an easier way. With Visual mode, select the text you
want to count words in. Then type g CTRL-G. The result:
Selected 5 of 293 Lines; 70 of 1884 Words; 359 of 10928 Bytes
For other ways to count words, lines and other items, see |count-items|.
==============================================================================
</font><hr></pre></blockquote>
==============================================================================
*12.4* Count words
Sometimes you have to write a text with a maximum number of words. Vim can
count the words for you.
When the whole file is what you want to count the words in, use this
command:
g CTRL-G
Do not type a space after the g, this is just used here to make the command
easy to read.
The output looks like this:
Col 1 of 0; Line 141 of 157; Word 748 of 774; Byte 4489 of 4976
You can see on which word you are (748), and the total number of words in the
file (774).
When the text is only part of a file, you could move to the start of the text,
type "g CTRL-G", move to the end of the text, type "g CTRL-G" again, and then
use your brain to compute the difference in the word position. That's a good
exercise, but there is an easier way. With Visual mode, select the text you
want to count words in. Then type g CTRL-G. The result:
Selected 5 of 293 Lines; 70 of 1884 Words; 359 of 10928 Bytes
For other ways to count words, lines and other items, see |count-items|.
==============================================================================
</font><hr></pre></blockquote>
Re: Zeichen zählen mit vi?
Danke erst mal, wo hast Du das denn her?
Aber ich brauche nicht nur Wörter, sondern alle Zeichen (inkl. Leerzeichen) - hast Du da auch etwas für mich? <img src="http://www.pl-forum.de/UltraBoard/Images/Wilk.gif" border="0" align="middle">
Julius
Aber ich brauche nicht nur Wörter, sondern alle Zeichen (inkl. Leerzeichen) - hast Du da auch etwas für mich? <img src="http://www.pl-forum.de/UltraBoard/Images/Wilk.gif" border="0" align="middle">
Julius
Re: Zeichen zählen mit vi?
""
""Danke erst mal, wo hast Du das denn her?
""
:help usr_toc
bzw.
Hilfe -> Handbuch
und dann weiter nach in Abschnitt 12 "Clever Tricks"
:help usr_12
""
""Aber ich brauche nicht nur Wörter, sondern alle Zeichen (inkl. Leerzeichen) - hast Du da auch etwas für mich?
""
<blockquote><pre><font size="1" face="">code:</font><hr><font face="Courier New" size="2">
When the whole file is what you want to count the words in, use this
command: >
g CTRL-G
Do not type a space after the g, this is just used here to make the command
easy to read.
The output looks like this:
Col 1 of 0; Line 141 of 157; Word 748 of 774; Byte 4489 of 4976 ~
^^^^
You can see on which word you are (748), and the total number of words in the
file (774).
</font><hr></pre></blockquote>
Wenn du nicht gerade eine Unicode-Datei (2Byte pro Zeichen) bearbeitest stimmt die Dateigrösse mit der Anzahl der Zeichen überein.
""Danke erst mal, wo hast Du das denn her?
""
:help usr_toc
bzw.
Hilfe -> Handbuch
und dann weiter nach in Abschnitt 12 "Clever Tricks"
:help usr_12
""
""Aber ich brauche nicht nur Wörter, sondern alle Zeichen (inkl. Leerzeichen) - hast Du da auch etwas für mich?
""
<blockquote><pre><font size="1" face="">code:</font><hr><font face="Courier New" size="2">
When the whole file is what you want to count the words in, use this
command: >
g CTRL-G
Do not type a space after the g, this is just used here to make the command
easy to read.
The output looks like this:
Col 1 of 0; Line 141 of 157; Word 748 of 774; Byte 4489 of 4976 ~
^^^^
You can see on which word you are (748), and the total number of words in the
file (774).
</font><hr></pre></blockquote>
Wenn du nicht gerade eine Unicode-Datei (2Byte pro Zeichen) bearbeitest stimmt die Dateigrösse mit der Anzahl der Zeichen überein.
Re: Zeichen zählen mit vi?
Kleines Detail am Rande: Newlines werden natürlich auch mitgezählt. Entweder es reicht die Genauigkeit auch so, oder man sollte noch mal die Anzahl der Zeilen von der Anzahl der Bytes abziehen (im Kopf, im bc oder in der Shell <img src="http://www.pl-forum.de/UltraBoard/Images/Happy.gif" border="0" align="middle"> ).
Jochen
Jochen