# vimhelp user manual -- chapter 06: using syntax highlighting # Copyright (C) 2006 Bram Moolenaar # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: vimhelp 7.0.122\n" "POT-Creation-Date: 2008-02-17 20:32+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf8\n" "Content-Transfer-Encoding: 8bit" # type: Plain text #: usr_06.txt:2 #, no-wrap msgid "*usr_06.txt*\tFor Vim version 7.0. Last change: 2006 Apr 24\n" msgstr "" # type: Plain text #: usr_06.txt:4 #, no-wrap msgid "\t\t VIM USER MANUAL - by Bram Moolenaar\n" msgstr "" # type: Plain text #: usr_06.txt:6 #, no-wrap msgid "\t\t\t Using syntax highlighting\n" msgstr "" # type: Plain text #: usr_06.txt:12 msgid "" "Black and white text is boring. With colors your file comes to life. This " "not only looks nice, it also speeds up your work. Change the colors used " "for the different sorts of text. Print your text, with the colors you see " "on the screen." msgstr "" # type: Plain text #: usr_06.txt:19 msgid "" "|06.1|\tSwitching it on |06.2|\tNo or wrong colors? |06.3|\tDifferent colors " "|06.4|\tWith colors or without colors |06.5|\tPrinting with colors " "|06.6|\tFurther reading" msgstr "" # type: Plain text #: usr_06.txt:23 #, no-wrap msgid "" " Next chapter: |usr_07.txt| Editing more than one file\n" " Previous chapter: |usr_05.txt| Set your settings\n" "Table of contents: |usr_toc.txt|\n" msgstr "" # type: Plain text #: usr_06.txt:24 usr_06.txt:50 usr_06.txt:135 usr_06.txt:189 usr_06.txt:266 usr_06.txt:272 #, no-wrap msgid "==============================================================================\n" msgstr "" # type: Plain text #: usr_06.txt:26 #, no-wrap msgid "*06.1*\tSwitching it on\n" msgstr "" # type: Plain text #: usr_06.txt:28 msgid "It all starts with one simple command: >" msgstr "" # type: Plain text #: usr_06.txt:30 #, no-wrap msgid "\t:syntax enable\n" msgstr "" # type: Plain text #: usr_06.txt:36 msgid "" "That should work in most situations to get color in your files. Vim will " "automagically detect the type of file and load the right syntax " "highlighting. Suddenly comments are blue, keywords brown and strings red. " "This makes it easy to overview the file. After a while you will find that " "black&white text slows you down!" msgstr "" # type: Plain text #: usr_06.txt:39 msgid "" "If you always want to use syntax highlighting, put the \":syntax enable\" " "command in your |vimrc| file." msgstr "" # type: Plain text #: usr_06.txt:42 msgid "" "If you want syntax highlighting only when the terminal supports colors, you " "can put this in your |vimrc| file: >" msgstr "" # type: Plain text #: usr_06.txt:46 #, no-wrap msgid "" "\tif &t_Co > 1\n" "\t syntax enable\n" "\tendif\n" msgstr "" # type: Plain text #: usr_06.txt:49 msgid "" "If you want syntax highlighting only in the GUI version, put the \":syntax " "enable\" command in your |gvimrc| file." msgstr "" # type: Plain text #: usr_06.txt:52 #, no-wrap msgid "*06.2*\tNo or wrong colors?\n" msgstr "" # type: Plain text #: usr_06.txt:54 msgid "There can be a number of reasons why you don't see colors:" msgstr "" # type: Plain text #: usr_06.txt:60 #, no-wrap msgid "" "- Your terminal does not support colors.\n" "\tVim will use bold, italic and underlined text, but this doesn't look\n" "\tvery nice. You probably will want to try to get a terminal with\n" "\tcolors. For Unix, I recommend the xterm from the XFree86 project:\n" "\t|xfree-xterm|.\n" msgstr "" # type: Plain text #: usr_06.txt:64 #, no-wrap msgid "" "- Your terminal does support colors, but Vim doesn't know this.\n" "\tMake sure your $TERM setting is correct. For example, when using an\n" "\txterm that supports colors: >\n" msgstr "" # type: Plain text #: usr_06.txt:68 #, no-wrap msgid "" "\t\tsetenv TERM xterm-color\n" "<\n" "\tor (depending on your shell): >\n" msgstr "" # type: Plain text #: usr_06.txt:70 #, no-wrap msgid "\t\tTERM=xterm-color; export TERM\n" msgstr "" # type: Plain text #: usr_06.txt:74 #, no-wrap msgid "" "<\tThe terminal name must match the terminal you are using. If it\n" "\tstill doesn't work, have a look at |xterm-color|, which shows a few\n" "\tways to make Vim display colors (not only for an xterm).\n" msgstr "" # type: Plain text #: usr_06.txt:78 #, no-wrap msgid "" "- The file type is not recognized.\n" "\tVim doesn't know all file types, and sometimes it's near to impossible\n" "\tto tell what language a file uses. Try this command: >\n" msgstr "" # type: Plain text #: usr_06.txt:84 #, no-wrap msgid "" "\t\t:set filetype\n" "<\n" "\tIf the result is \"filetype=\" then the problem is indeed that Vim\n" "\tdoesn't know what type of file this is. You can set the type\n" "\tmanually: >\n" msgstr "" # type: Plain text #: usr_06.txt:86 #, no-wrap msgid "\t\t:set filetype=fortran\n" msgstr "" # type: Plain text #: usr_06.txt:93 #, no-wrap msgid "" "<\tTo see which types are available, look in the directory\n" "\t$VIMRUNTIME/syntax. For the GUI you can use the Syntax menu.\n" "\tSetting the filetype can also be done with a |modeline|, so that the\n" "\tfile will be highlighted each time you edit it. For example, this\n" "\tline can be used in a Makefile (put it near the start or end of the\n" "\tfile): >\n" msgstr "" # type: Plain text #: usr_06.txt:95 #, no-wrap msgid "\t\t# vim: syntax=make\n" msgstr "" # type: Plain text #: usr_06.txt:99 #, no-wrap msgid "" "<\tYou might know how to detect the file type yourself. Often the file\n" "\tname extension (after the dot) can be used.\n" "\tSee |new-filetype| for how to tell Vim to detect that file type.\n" msgstr "" # type: Plain text #: usr_06.txt:104 #, no-wrap msgid "" "- There is no highlighting for your file type.\n" "\tYou could try using a similar file type by manually setting it as\n" "\tmentioned above. If that isn't good enough, you can write your own\n" "\tsyntax file, see |mysyntaxfile|.\n" msgstr "" # type: Plain text #: usr_06.txt:107 msgid "Or the colors could be wrong:" msgstr "" # type: Plain text #: usr_06.txt:114 #, no-wrap msgid "" "- The colored text is very hard to read.\n" "\tVim guesses the background color that you are using. If it is black\n" "\t(or another dark color) it will use light colors for text. If it is\n" "\twhite (or another light color) it will use dark colors for text. If\n" "\tVim guessed wrong the text will be hard to read. To solve this, set\n" "\tthe 'background' option. For a dark background: >\n" msgstr "" # type: Plain text #: usr_06.txt:116 #, no-wrap msgid "\t\t:set background=dark\n" msgstr "" # type: Plain text #: usr_06.txt:118 msgid "<\tAnd for a light background: >" msgstr "" # type: Plain text #: usr_06.txt:120 #, no-wrap msgid "\t\t:set background=light\n" msgstr "" # type: Plain text #: usr_06.txt:125 #, no-wrap msgid "" "<\tMake sure you put this _before_ the \":syntax enable\" command,\n" "\totherwise the colors will already have been set. You could do\n" "\t\":syntax reset\" after setting 'background' to make Vim set the default\n" "\tcolors again.\n" msgstr "" # type: Plain text #: usr_06.txt:134 #, no-wrap msgid "" "- The colors are wrong when scrolling bottom to top.\n" "\tVim doesn't read the whole file to parse the text. It starts parsing\n" "\twherever you are viewing the file. That saves a lot of time, but\n" "\tsometimes the colors are wrong. A simple fix is hitting CTRL-L. Or\n" "\tscroll back a bit and then forward again.\n" "\tFor a real fix, see |:syn-sync|. Some syntax files have a way to make\n" "\tit look further back, see the help for the specific syntax file. For\n" "\texample, |tex.vim| for the TeX syntax.\n" msgstr "" # type: Plain text #: usr_06.txt:137 #, no-wrap msgid "*06.3*\tDifferent colors\t\t\t\t*:syn-default-override*\n" msgstr "" # type: Plain text #: usr_06.txt:140 msgid "" "If you don't like the default colors, you can select another color scheme. " "In the GUI use the Edit/Color Scheme menu. You can also type the command: >" msgstr "" # type: Plain text #: usr_06.txt:142 #, no-wrap msgid "\t:colorscheme evening\n" msgstr "" # type: Plain text #: usr_06.txt:145 msgid "" "\"evening\" is the name of the color scheme. There are several others you " "might want to try out. Look in the directory $VIMRUNTIME/colors." msgstr "" # type: Plain text #: usr_06.txt:148 msgid "" "When you found the color scheme that you like, add the \":colorscheme\" " "command to your |vimrc| file." msgstr "" # type: Plain text #: usr_06.txt:150 msgid "You could also write your own color scheme. This is how you do it:" msgstr "" # type: Bullet: '1. ' #: usr_06.txt:153 msgid "" "Select a color scheme that comes close. Copy this file to your own Vim " "directory. For Unix, this should work: >" msgstr "" # type: Plain text #: usr_06.txt:158 #, no-wrap msgid "" "\t!mkdir ~/.vim/colors\n" "\t!cp $VIMRUNTIME/colors/morning.vim ~/.vim/colors/mine.vim\n" "<\n" " This is done from Vim, because it knows the value of $VIMRUNTIME.\n" msgstr "" # type: Bullet: '2. ' #: usr_06.txt:160 msgid "Edit the color scheme file. These entries are useful:" msgstr "" # type: Plain text #: usr_06.txt:168 #, no-wrap msgid "" "\tterm\t\tattributes in a B&W terminal\n" "\tcterm\t\tattributes in a color terminal\n" "\tctermfg\t\tforeground color in a color terminal\n" "\tctermbg\t\tbackground color in a color terminal\n" "\tgui\t\tattributes in the GUI\n" "\tguifg\t\tforeground color in the GUI\n" "\tguibg\t\tbackground color in the GUI\n" msgstr "" # type: Plain text #: usr_06.txt:170 #, no-wrap msgid " For example, to make comments green: >\n" msgstr "" # type: Plain text #: usr_06.txt:176 #, no-wrap msgid "" "\t:highlight Comment ctermfg=green guifg=green\n" "<\n" " Attributes you can use for \"cterm\" and \"gui\" are \"bold\" and " "\"underline\".\n" " If you want both, use \"bold,underline\". For details see the " "|:highlight|\n" " command.\n" msgstr "" # type: Bullet: '3. ' #: usr_06.txt:178 msgid "Tell Vim to always use your color scheme. Put this line in your |vimrc|: >" msgstr "" # type: Plain text #: usr_06.txt:180 #, no-wrap msgid "\tcolorscheme mine\n" msgstr "" # type: Plain text #: usr_06.txt:183 msgid "" "If you want to see what the most often used color combinations look like, " "use this command: >" msgstr "" # type: Plain text #: usr_06.txt:185 #, no-wrap msgid "\t:runtime syntax/colortest.vim\n" msgstr "" # type: Plain text #: usr_06.txt:188 msgid "" "You will see text in various color combinations. You can check which ones " "are readable and look nice." msgstr "" # type: Plain text #: usr_06.txt:191 #, no-wrap msgid "*06.4*\tWith colors or without colors\n" msgstr "" # type: Plain text #: usr_06.txt:194 msgid "" "Displaying text in color takes a lot of effort. If you find the displaying " "too slow, you might want to disable syntax highlighting for a moment: >" msgstr "" # type: Plain text #: usr_06.txt:196 #, no-wrap msgid "\t:syntax clear\n" msgstr "" # type: Plain text #: usr_06.txt:198 msgid "When editing another file (or the same one) the colors will come back." msgstr "" # type: Plain text #: usr_06.txt:201 #, no-wrap msgid "" "\t\t\t\t\t\t\t*:syn-off*\n" "If you want to stop highlighting completely use: >\n" msgstr "" # type: Plain text #: usr_06.txt:203 #, no-wrap msgid "\t:syntax off\n" msgstr "" # type: Plain text #: usr_06.txt:206 msgid "" "This will completely disable syntax highlighting and remove it immediately " "for all buffers." msgstr "" # type: Plain text #: usr_06.txt:209 #, no-wrap msgid "" "\t\t\t\t\t\t\t*:syn-manual*\n" "If you want syntax highlighting only for specific files, use this: >\n" msgstr "" # type: Plain text #: usr_06.txt:211 #, no-wrap msgid "\t:syntax manual\n" msgstr "" # type: Plain text #: usr_06.txt:215 msgid "" "This will enable the syntax highlighting, but not switch it on automatically " "when starting to edit a buffer. To switch highlighting on for the current " "buffer, set the 'syntax' option: >" msgstr "" # type: Plain text #: usr_06.txt:218 #, no-wrap msgid "" "\t:set syntax=ON\n" "<\n" "==============================================================================\n" msgstr "" # type: Plain text #: usr_06.txt:220 #, no-wrap msgid "*06.5*\tPrinting with colors\t\t\t\t*syntax-printing*\n" msgstr "" # type: Plain text #: usr_06.txt:222 msgid "" "In the MS-Windows version you can print the current file with this command: " ">" msgstr "" # type: Plain text #: usr_06.txt:224 #, no-wrap msgid "\t:hardcopy\n" msgstr "" # type: Plain text #: usr_06.txt:229 msgid "" "You will get the usual printer dialog, where you can select the printer and " "a few settings. If you have a color printer, the paper output should look " "the same as what you see inside Vim. But when you use a dark background the " "colors will be adjusted to look good on white paper." msgstr "" # type: Plain text #: usr_06.txt:235 #, no-wrap msgid "" "There are several options that change the way Vim prints:\n" "\t'printdevice'\n" "\t'printheader'\n" "\t'printfont'\n" "\t'printoptions'\n" msgstr "" # type: Plain text #: usr_06.txt:238 msgid "" "To print only a range of lines, use Visual mode to select the lines and then " "type the command: >" msgstr "" # type: Plain text #: usr_06.txt:240 #, no-wrap msgid "\tv100j:hardcopy\n" msgstr "" # type: Plain text #: usr_06.txt:244 msgid "" "\"v\" starts Visual mode. \"100j\" moves a hundred lines down, they will be " "highlighted. Then \":hardcopy\" will print those lines. You can use other " "commands to move in Visual mode, of course." msgstr "" # type: Plain text #: usr_06.txt:248 msgid "" "This also works on Unix, if you have a PostScript printer. Otherwise, you " "will have to do a bit more work. You need to convert the text to HTML " "first, and then print it from a web browser such as Netscape." msgstr "" # type: Plain text #: usr_06.txt:250 msgid "Convert the current file to HTML with this command: >" msgstr "" # type: Plain text #: usr_06.txt:252 #, no-wrap msgid "\t:source $VIMRUNTIME/syntax/2html.vim\n" msgstr "" # type: Plain text #: usr_06.txt:258 #, no-wrap msgid "" "You will see it crunching away, this can take quite a while for a large " "file.\n" "Some time later another window shows the HTML code. Now write this " "somewhere\n" "(doesn't matter where, you throw it away later):\n" ">\n" "\t:write main.c.html\n" msgstr "" # type: Plain text #: usr_06.txt:262 msgid "" "Open this file in your favorite browser and print it from there. If all " "goes well, the output should look exactly as it does in Vim. See " "|2html.vim| for details. Don't forget to delete the HTML file when you are " "done with it." msgstr "" # type: Plain text #: usr_06.txt:265 msgid "" "Instead of printing, you could also put the HTML file on a web server, and " "let others look at the colored text." msgstr "" # type: Plain text #: usr_06.txt:268 #, no-wrap msgid "*06.6*\tFurther reading\n" msgstr "" # type: Plain text #: usr_06.txt:271 #, no-wrap msgid "" "|usr_44.txt| Your own syntax highlighted.\n" "|syntax| All the details.\n" msgstr "" # type: Plain text #: usr_06.txt:275 msgid "Next chapter: |usr_07.txt| Editing more than one file" msgstr "" # type: Plain text #: usr_06.txt:276 msgid "Copyright: see |manual-copyright| vim:tw=78:ts=8:ft=help:norl:" msgstr ""