# Vim User Manual Chp 43: Using filetypes # Copyright (C) 2006 Bram Moolenaar. # This file is distributed under the same license as the vim package. # Florian 'eix' Rehnisch , 2008. # msgid "" msgstr "" "Project-Id-Version: vimhelp 7.0.122\n" "POT-Creation-Date: 2010-11-21 18:58+0100\n" "PO-Revision-Date: 2010-11-21 19:00+0100\n" "Last-Translator: Florian 'eix' Rehnisch \n" "Language-Team: German \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf8\n" "Content-Transfer-Encoding: 8bit\n" # type: Plain text #. type: Plain text #: usr_43.txt:2 #, no-wrap msgid "*usr_43.txt*\tFor Vim version 7.3. Last change: 2008 Dec 28\n" msgstr "*usr_43.txt*\tFür Vim Version 7.3. Letzte Änderung: 2008-Dez-28\n" # type: Plain text #. type: Plain text #: usr_43.txt:4 #, no-wrap msgid "\t\t VIM USER MANUAL - by Bram Moolenaar\n" msgstr "\t\t VIM-BENUTZERHANDBUCH - von Bram Moolenaar\n" # type: Plain text #. type: Plain text #: usr_43.txt:6 #, no-wrap msgid "\t\t\t Using filetypes\n" msgstr "\t\t\t Dateitypen (filetypes) benutzen\n" # type: Plain text #. type: Plain text #: usr_43.txt:12 msgid "" "When you are editing a file of a certain type, for example a C program or a " "shell script, you often use the same option settings and mappings. You " "quickly get tired of manually setting these each time. This chapter " "explains how to do it automatically." msgstr "" "Wenn Sie eine Datei von einem bestimmten Typ editieren, zum Beispiel ein " "C-Programm oder ein Shell-Skript, benutzen Sie oft dieselben Einstellungen " "und Tastaturbelegungen. Sie werden schnell müde, diese jedes Mal von Hand " "zu setzen. Dieses Kapitel erklärt, wie man es automatisiert." # type: Plain text #. type: Plain text #: usr_43.txt:15 msgid "|43.1|\tPlugins for a filetype |43.2|\tAdding a filetype" msgstr "" "|43.1|\tPlugins für einen Dateityp\n" "|43.2|\tEinen Dateityp hinzufügen" # type: Plain text #. type: Plain text #: usr_43.txt:19 #, no-wrap msgid "" " Next chapter: |usr_44.txt| Your own syntax highlighted\n" " Previous chapter: |usr_42.txt| Add new menus\n" "Table of contents: |usr_toc.txt|\n" msgstr "" "Nächstes Kapitel: |usr_44.txt| Eigene Syntax-Hervorhebungen\n" " Voriges Kapitel: |usr_42.txt| Neue Menüs hinzufügen\n" "Inhaltsübersicht: |usr_toc.txt|\n" # type: Plain text #. type: Plain text #: usr_43.txt:20 usr_43.txt:70 usr_43.txt:169 #, no-wrap msgid "" "==============================================================================\n" msgstr "" "==============================================================================\n" # type: Plain text #. type: Plain text #: usr_43.txt:22 #, no-wrap msgid "*43.1*\tPlugins for a filetype\t\t\t\t*filetype-plugin*\n" msgstr "*43.1*\tPlugins für einen Dateityp\t\t\t\t*filetype-plugin*\n" # type: Plain text #. type: Plain text #: usr_43.txt:28 msgid "" "How to start using filetype plugins has already been discussed here: |add-" "filetype-plugin|. But you probably are not satisfied with the default " "settings, because they have been kept minimal. Suppose that for C files " "you " "want to set the 'softtabstop' option to 4 and define a mapping to insert a " "three-line comment. You do this with only two steps:" msgstr "" "Wie mit der Benutzung von Dateitypen-Plugins begonnen wird, wurde bereits " "unter |add-filetype-plugin| besprochen. Aber möglicherweise sind Sie mit " "den Standard-Vorgaben nicht zufrieden, weil diese minimal gehalten wurden. " "Angenommen, Sie wollen für C-Dateien die Option 'softtabstop' auf 4 setzen " "und eine Tastenbelegung definieren, welche einen dreizeiligen Kommentar " "einfügt. Dies geht mit nur zwei Schritten:" # type: Plain text #. type: Plain text #: usr_43.txt:32 #, no-wrap msgid "" "\t\t\t\t\t\t\t*your-runtime-dir*\n" "1. Create your own runtime directory. On Unix this usually is \"~/.vim\". " "In\n" " this directory create the \"ftplugin\" directory: >\n" msgstr "" "\t\t\t\t\t\t\t*your-runtime-dir*\n" "1. Erzeugen Sie Ihr eigene Laufzeit-Verzeichnis. Unter Unix ist dies für\n" "gewöhnlich »~/.vim«. Erzeugen Sie in diesem Verzeichnis das " "Verzeichnis\n" "»ftplugin«: >\n" # type: Plain text #. type: Plain text #: usr_43.txt:38 #, no-wrap msgid "" "\tmkdir ~/.vim\n" "\tmkdir ~/.vim/ftplugin\n" "<\n" " When you are not on Unix, check the value of the 'runtimepath' option " "to\n" " see where Vim will look for the \"ftplugin\" directory: >\n" msgstr "" "\tmkdir ~/.vim\n" "\tmkdir ~/.vim/ftplugin\n" "<\n" " Falls Sie nicht unter Unix arbeiten, prüfen Sie den Wert der Option\n" "'runtimepath', um zu sehen, wo Vim nach dem Verzeichnis »ftplugin« sucht: " ">\n" # type: Plain text #. type: Plain text #: usr_43.txt:40 #, no-wrap msgid "\tset runtimepath\n" msgstr "\tset runtimepath\n" # type: Plain text #. type: Plain text #: usr_43.txt:44 #, no-wrap msgid "" "< You would normally use the first directory name (before the first " "comma).\n" " You might want to prepend a directory name to the 'runtimepath' option " "in\n" " your |vimrc| file if you don't like the default value.\n" msgstr "" "< Sie werden normalerweise den ersten Verzeichnisnamen (vor dem ersten " "Komma)\n" "benutzen. Möglicherweise wollen Sie der Option 'runtimepath' ein " "Verzeichnis\n" "in Ihrer Datei |vimrc| voranstellen, falls Ihnen die Vorgabe nicht " "gefällt.\n" # type: Bullet: '2. ' #. type: Bullet: '2. ' #: usr_43.txt:46 msgid "Create the file \"~/.vim/ftplugin/c.vim\", with the contents: >" msgstr "" "Erzeugen Sie die Datei »~/.vim/ftplugin/c.vim« mit folgendem Inhalt: >" # type: Plain text #. type: Plain text #: usr_43.txt:49 #, no-wrap msgid "" "\tsetlocal softtabstop=4\n" "\tnoremap c o/**************/\n" msgstr "" "\tsetlocal softtabstop=4\n" "\tnoremap c o/**************/\n" # type: Plain text #. type: Plain text #: usr_43.txt:56 msgid "" "Try editing a C file. You should notice that the 'softtabstop' option is " "set to 4. But when you edit another file it's reset to the default zero. " "That is because the \":setlocal\" command was used. This sets the " "'softtabstop' option only locally to the buffer. As soon as you edit " "another buffer, it will be set to the value set for that buffer. For a new " "buffer it will get the default value or the value from the last \":set\" " "command." msgstr "" "Versuchen Sie nun eine C-Datei zu editieren. Sie sollten bemerken, dass " "die Option 'softtabstop' auf 4 gesetzt wurde. Wenn Sie aber eine andere " "Datei editieren, wird sie auf das vorgabemäßige 0 zurückgesetzt. Das " "ist so, weil der Befehl »:setlocal« benutzt wurde. Dieser setzt die " "Option 'settabstop' nur für den lokalen Puffer. Sobald Sie einen anderen " "Puffer editieren, wird sie auf den Vorgabewert für diesen Puffer gesetzt. " "Für einen neuen Puffer ist dies der Standardwert oder der Wert des letzten " "»:set«-Befehls." # type: Plain text # FIXME: ticks #. type: Plain text #: usr_43.txt:62 msgid "" "Likewise, the mapping for \"\\c\" will disappear when editing another " "buffer. The \":map \" command creates a mapping that is local to " "the current buffer. This works with any mapping command: \":map!\", \":vmap" "\", etc. The || in the mapping is replaced with the value of " "the \"maplocalleader\" variable." msgstr "" "Desweiteren verschwindet die Tastaturbelegung für »\\c«, wenn ein " "anderer Puffer editiert wird. Der Befehl »:map « erzeugt eine " "Tastenbelegung, die lokal zu dem aktuellen Puffer ist. Dies funktioniert " "mit jedem Belegungsbefehl: »:map!«, »:vmap« usw. Das | in " "der Belegung wird durch den Wert der Variablen »maplocalleader« ersetzt." # type: Plain text #. type: Plain text #: usr_43.txt:64 msgid "You can find examples for filetype plugins in this directory: >" msgstr "" "In diesem Verzeichnis können Sie Beispiele für Dateitypen-Plugins finden: " ">" # type: Plain text #. type: Plain text #: usr_43.txt:66 #, no-wrap msgid "\t$VIMRUNTIME/ftplugin/\n" msgstr "\t$VIMRUNTIME/ftplugin/\n" # type: Plain text #. type: Plain text #: usr_43.txt:69 msgid "" "More details about writing a filetype plugin can be found here: |write-" "plugin|." msgstr "" "Weitere Details über das Schreiben von Dateitypen-Plugins können unter " "|write-plugin| gefunden werden." # type: Plain text #. type: Plain text #: usr_43.txt:72 #, no-wrap msgid "*43.2*\tAdding a filetype\n" msgstr "*43.2*\tEinen Dateityp hinzufügen\n" # type: Plain text #. type: Plain text #: usr_43.txt:76 msgid "" "If you are using a type of file that is not recognized by Vim, this is how " "to get it recognized. You need a runtime directory of your own. See |your-" "runtime-dir| above." msgstr "" "Falls Sie einen Dateityp benutzen, der von Vim nicht erkannt wird, bekommen " "Sie ihn folgendermaßen erkannt. Sie brauchen ein eigenes " "Laufzeitverzeichnis. Siehe oben |your-runtime-dir|." # type: Plain text #. type: Plain text #: usr_43.txt:79 msgid "" "Create a file \"filetype.vim\" which contains an autocommand for your " "filetype. (Autocommands were explained in section |40.3|.) Example: >" msgstr "" "Erzeugen Sie eine Datei »filetype.vim«, die einen automatischen Befehl " "für Ihren Dateityp enthält. (Automatische Befehle werden in Abschnitt " "|40.3| erläutert.) Zum Beispiel: >" # type: Plain text #. type: Plain text #: usr_43.txt:83 #, no-wrap msgid "" "\taugroup filetypedetect\n" "\tau BufNewFile,BufRead *.xyz\tsetf xyz\n" "\taugroup END\n" msgstr "" "\taugroup filetypedetect\n" "\tau BufNewFile,BufRead *.xyz\tsetf xyz\n" "\taugroup END\n" # type: Plain text #. type: Plain text #: usr_43.txt:90 msgid "" "This will recognize all files that end in \".xyz\" as the \"xyz\" filetype. " " " "The \":augroup\" commands put this autocommand in the \"filetypedetect\" " "group. This allows removing all autocommands for filetype detection when " "doing \":filetype off\". The \"setf\" command will set the 'filetype' " "option to its argument, unless it was set already. This will make sure " "that " "'filetype' isn't set twice." msgstr "" "Dies lässt alle Dateien, die auf ».xyz« enden, als den Dateityp xyz " "erkennen. Die Befehle »:augroup« setzen diesen automatischen Befehl in " "die Gruppe »filetypedetect«. Dies erlaubt es, alle automatischen Befehle " "für die Dateityperkennung zu entfernen, wenn der Befehl »:filetype off« " "gegeben wird. Der Befehl »setf« setzt die Option 'filetype' auf sein " "Argument, wenn er es nicht schon ohnehin war. Dies stellt sicher, dass " "'filetype' nicht zweimal gesetzt wird." # type: Plain text #. type: Plain text #: usr_43.txt:95 msgid "" "You can use many different patterns to match the name of your file. " "Directory names can also be included. See |autocmd-patterns|. For " "example, " "the files under \"/usr/share/scripts/\" are all \"ruby\" files, but don't " "have the expected file name extension. Adding this to the example above: >" msgstr "" "Sie können viele verschiedene übereinstimmungsmuster für den Namen Ihrer " "Datei benutzen. Verzeichnisnamen können ebenfalls einbezogen werden. " "Siehe |autocmd-patterns|. Zum Beispiel sind die Dateien unter " "»/usr/share/scripts/« alle Ruby-Dateien, aber haben nicht die erwartete " "Datei-Endung. Fügen wir dies obigem Beispiel hinzu: >" # type: Plain text #. type: Plain text #: usr_43.txt:100 #, no-wrap msgid "" "\taugroup filetypedetect\n" "\tau BufNewFile,BufRead *.xyz\t\t\tsetf xyz\n" "\tau BufNewFile,BufRead /usr/share/scripts/*\tsetf ruby\n" "\taugroup END\n" msgstr "" "\taugroup filetypedetect\n" "\tau BufNewFile,BufRead *.xyz\t\t\tsetf xyz\n" "\tau BufNewFile,BufRead /usr/share/scripts/*\tsetf ruby\n" "\taugroup END\n" # type: Plain text #. type: Plain text #: usr_43.txt:107 #, no-wrap msgid "" "However, if you now edit a file /usr/share/scripts/README.txt, this is not " "a\n" "ruby file. The danger of a pattern ending in \"*\" is that it quickly " "matches\n" "too many files. To avoid trouble with this, put the filetype.vim file in\n" "another directory, one that is at the end of 'runtimepath'. For Unix for\n" "example, you could use \"~/.vim/after/filetype.vim\".\n" " You now put the detection of text files in ~/.vim/filetype.vim: >\n" msgstr "" "Falls Sie aber nun eine Datei /usr/share/scripts/READE.txt editieren, ist\n" "diese keine Ruby-Datei. Die Gefahr von Mustern, die auf »*« enden ist, " "dass\n" "schnell zu viele Dateien erfasst werden. Um dieses Problem zu vermeiden,\n" "legen Sie die Datei in ein anderes Verzeichnis, eines, dass am Ende von\n" "'runtimepath' ist. Für Unix könnten Sie zum Beispiel\n" "»~/.vim/after/filetype.vim« benutzen.\n" " Jetzt packen Sie die Erkennung von Textdateien in ~/.vim/filetype.vim: >\n" # type: Plain text #. type: Plain text #: usr_43.txt:111 #, no-wrap msgid "" "\taugroup filetypedetect\n" "\tau BufNewFile,BufRead *.txt\t\t\tsetf text\n" "\taugroup END\n" msgstr "" "\taugroup filetypedetect\n" "\tau BufNewFile,BufRead *.txt\t\t\tsetf text\n" "\taugroup END\n" # type: Plain text #. type: Plain text #: usr_43.txt:114 msgid "" "That file is found in 'runtimepath' first. Then use this in ~/.vim/after/" "filetype.vim, which is found last: >" msgstr "" "Diese Datei wird zuerst in 'runtimepath' gefunden. Dann packen Sie dies in " "die ~/.vim/after/filetype.vim, welche zuletzt gefunden wird: >" # type: Plain text #. type: Plain text #: usr_43.txt:118 #, no-wrap msgid "" "\taugroup filetypedetect\n" "\tau BufNewFile,BufRead /usr/share/scripts/*\tsetf ruby\n" "\taugroup END\n" msgstr "" "\taugroup filetypedetect\n" "\tau BufNewFile,BufRead /usr/share/scripts/*\tsetf ruby\n" "\taugroup END\n" # type: Plain text #. type: Plain text #: usr_43.txt:133 #, no-wrap msgid "" "What will happen now is that Vim searches for \"filetype.vim\" files in " "each\n" "directory in 'runtimepath'. First ~/.vim/filetype.vim is found. The\n" "autocommand to catch *.txt files is defined there. Then Vim finds the\n" "filetype.vim file in $VIMRUNTIME, which is halfway 'runtimepath'. Finally\n" "~/.vim/after/filetype.vim is found and the autocommand for detecting ruby\n" "files in /usr/share/scripts is added.\n" " When you now edit /usr/share/scripts/README.txt, the autocommands are\n" "checked in the order in which they were defined. The *.txt pattern " "matches,\n" "thus \"setf text\" is executed to set the filetype to \"text\". The " "pattern for\n" "ruby matches too, and the \"setf ruby\" is executed. But since 'filetype' " "was\n" "already set to \"text\", nothing happens here.\n" " When you edit the file /usr/share/scripts/foobar the same autocommands " "are\n" "checked. Only the one for ruby matches and \"setf ruby\" sets 'filetype' " "to\n" "ruby.\n" msgstr "" "Was nun passiert ist, dass Vim in jedem Verzeichnis in 'runtimepath' nach\n" "einer Datei »filetype.vim« sucht. Zuerst wird ~/.vim/filetype.vim " "gefunden.\n" "Der automatische Befehl um *.txt Dateien zu erkennen wird dort definiert.\n" "Dann findet Vim die Datei filetype.vim in $VIMRUNTIME, was in der Mitte " "von\n" "'runtimepath' ist. Schließlich wird ~/.vim/after/filetype.vim gefunden, " "und\n" "der automatische Befehl für die Erkennung von Ruby-Dateien in\n" "/usr/share/scripts wird hinzugefügt.\n" " Wenn Sie nun /usr/share/scripts/README.txt editieren, werden die\n" "automatischen Befehle in der Reihenfolge überprüft, in der sie definiert\n" "wurden. Das Muster *.txt trifft, also wird »setf text« ausgeführt, um " "den\n" "Dateityp auf »text« zu setzen. Das Muster für Ruby trifft ebenfalls, " "und\n" "»setf ruby« wird ausgeführt. Aber weil 'filetype' bereits auf »text« " "gesetzt\n" "war, passiert hier nichts.\n" " Wenn Sie die Datei /usr/share/scripts/foobar editieren, werden " "dieselben\n" "automatischen Befehle überprüft. Nur der für Ruby passt, und »setf " "ruby«\n" "setzt 'filetype' auf Ruby.\n" # type: Plain text #. type: Plain text #: usr_43.txt:136 msgid "RECOGNIZING BY CONTENTS" msgstr "ERKENNUNG NACH INHALT" # type: Plain text #. type: Plain text #: usr_43.txt:140 msgid "" "If your file cannot be recognized by its file name, you might be able to " "recognize it by its contents. For example, many script files start with a " "line like:" msgstr "" "Falls Ihre Datei nicht am Dateinamen erkannt werden kann, mag es sein, dass " "sie sich an ihrem Inhalt erkennen lässt. Zum Beispiel beginnen viele " "Skript-Dateien mit einer Zeile wie dieser:" # type: Plain text #. type: Plain text #: usr_43.txt:142 #, no-wrap msgid "\t#!/bin/xyz ~\n" msgstr "\t#!/bin/xyz ~\n" # type: Plain text #. type: Plain text #: usr_43.txt:145 msgid "" "To recognize this script create a file \"scripts.vim\" in your runtime " "directory (same place where filetype.vim goes). It might look like this: >" msgstr "" "Um dieses Skript zu erkennen, erzeugen Sie eine Datei »scripts.vim« in " "Ihrem Laufzeit-Verzeichnis (an derselben Stelle wie filetype.vim. Sie " "könnte so aussehen: >" # type: Plain text #. type: Plain text #: usr_43.txt:152 #, no-wrap msgid "" "\tif did_filetype()\n" "\t finish\n" "\tendif\n" "\tif getline(1) =~ '^#!.*[/\\\\]xyz\\>'\n" "\t setf xyz\n" "\tendif\n" msgstr "" "\tif did_filetype()\n" "\t finish\n" "\tendif\n" "\tif getline(1) =~ '^#!.*[/\\\\]xyz\\>'\n" "\t setf xyz\n" "\tendif\n" # type: Plain text #. type: Plain text #: usr_43.txt:159 #, no-wrap msgid "" "The first check with did_filetype() is to avoid that you will check the\n" "contents of files for which the filetype was already detected by the file\n" "name. That avoids wasting time on checking the file when the \"setf\" " "command\n" "won't do anything.\n" " The scripts.vim file is sourced by an autocommand in the default\n" "filetype.vim file. Therefore, the order of checks is:\n" msgstr "" "Die erste Abfrage auf did_filetype() geschieht, um zu vermeiden, dass\n" "Dateien, die bereits nach ihrem Dateinamen erkannt wurden, auf ihren " "Inhalt\n" "untersucht werden. Dies spart Zeit, die auf das Prüfen der Datei " "verwandt\n" "würde, wenn der Befehl »setf« ohnehin ohne Wirkung bliebe.\n" " Die Datei scripts.vim wird von einem automatischen Befehl in der\n" "standardmäßigen filetype.vim eingelesen. Demnach ist die\n" "Überprüfungsreihenfolge:\n" # type: Bullet: ' 1. ' #. type: Bullet: ' 1. ' #: usr_43.txt:165 msgid "filetype.vim files before $VIMRUNTIME in 'runtimepath'" msgstr "Dateien filetype.vim vor $VIMRUNTIME in 'runtimepath'" # type: Bullet: ' 2. ' #. type: Bullet: ' 2. ' #: usr_43.txt:165 msgid "first part of $VIMRUNTIME/filetype.vim" msgstr "Der erste Teil von $VIMRUNTIME/filetype.vim" # type: Bullet: ' 3. ' #. type: Bullet: ' 3. ' #: usr_43.txt:165 msgid "all scripts.vim files in 'runtimepath'" msgstr "Alle Dateien scripts.vim in 'runtimepath'" # type: Bullet: ' 4. ' #. type: Bullet: ' 4. ' #: usr_43.txt:165 msgid "remainder of $VIMRUNTIME/filetype.vim" msgstr "Der Rest von $VIMRUNTIME/filetype.vim" # type: Bullet: ' 5. ' #. type: Bullet: ' 5. ' #: usr_43.txt:165 msgid "filetype.vim files after $VIMRUNTIME in 'runtimepath'" msgstr "Dateien filetype.vim nach $VIMRUNTIME in 'runtimepath'" # type: Plain text #. type: Plain text #: usr_43.txt:168 msgid "" "If this is not sufficient for you, add an autocommand that matches all " "files " "and sources a script or executes a function to check the contents of the " "file." msgstr "" "Falls Ihnen dies nicht ausreicht, fügen Sie einen automatischen Befehl, " "der auf alle Dateien passt und ein Skript einliest, oder eine Funktion " "ausführt, die auf den Inhalt der Datei prüft, hinzu." # type: Plain text #. type: Plain text #: usr_43.txt:172 msgid "Next chapter: |usr_44.txt| Your own syntax highlighted" msgstr "Nächstes Kapitel: |usr_44.txt| Eigene Syntax-Hervorhebungen" # type: Plain text #. type: Plain text #: usr_43.txt:173 msgid "Copyright: see |manual-copyright| vim:tw=78:ts=8:ft=help:norl:" msgstr "Copyright: siehe |manual-copyright| vim:tw=78:ts=8:ft=help:norl:"