# Vim User Manual Chapter 20:Typing command-line commands quickly # Copyright (C) 1988-2006 Bram Moolenaar. # This file is distributed under the same license as the vim documentation. # FIRST AUTHOR , YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: vimhelp 7.0\n" "POT-Creation-Date: 2009-10-04 18:40+0200\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_20.txt:2 #, no-wrap msgid "*usr_20.txt*\tFor Vim version 7.0. Last change: 2006 Apr 24\n" msgstr "" # type: Plain text #: usr_20.txt:4 #, no-wrap msgid "\t\t VIM USER MANUAL - by Bram Moolenaar\n" msgstr "" # type: Plain text #: usr_20.txt:6 #, no-wrap msgid "\t\t Typing command-line commands quickly\n" msgstr "" # type: Plain text #: usr_20.txt:11 msgid "" "Vim has a few generic features that makes it easier to enter commands. " "Colon commands can be abbreviated, edited and repeated. Completion is " "available for nearly everything." msgstr "" # type: Plain text #: usr_20.txt:17 msgid "" "|20.1|\tCommand line editing |20.2|\tCommand line abbreviations " "|20.3|\tCommand line completion |20.4|\tCommand line history |20.5|\tCommand " "line window" msgstr "" # type: Plain text #: usr_20.txt:21 #, no-wrap msgid "" " Next chapter: |usr_21.txt| Go away and come back\n" " Previous chapter: |usr_12.txt| Clever tricks\n" "Table of contents: |usr_toc.txt|\n" msgstr "" # type: Plain text #: usr_20.txt:22 usr_20.txt:113 usr_20.txt:158 usr_20.txt:285 usr_20.txt:327 usr_20.txt:380 #, no-wrap msgid "==============================================================================\n" msgstr "" # type: Plain text #: usr_20.txt:24 #, no-wrap msgid "*20.1*\tCommand line editing\n" msgstr "" # type: Plain text #: usr_20.txt:29 msgid "" "When you use a colon (:) command or search for a string with / or ?, Vim " "puts the cursor on the bottom of the screen. There you type the command or " "search pattern. This is called the Command line. Also when it's used for " "entering a search command." msgstr "" # type: Plain text #: usr_20.txt:34 #, no-wrap msgid "" "The most obvious way to edit the command you type is by pressing the " "key.\n" "This erases the character before the cursor. To erase another character,\n" "typed earlier, first move the cursor with the cursor keys.\n" " For example, you have typed this: >\n" msgstr "" # type: Plain text #: usr_20.txt:36 #, no-wrap msgid "\t:s/col/pig/\n" msgstr "" # type: Plain text #: usr_20.txt:40 msgid "" "Before you hit , you notice that \"col\" should be \"cow\". To " "correct this, you type five times. The cursor is now just after " "\"col\". Type and \"w\" to correct: >" msgstr "" # type: Plain text #: usr_20.txt:42 #, no-wrap msgid "\t:s/cow/pig/\n" msgstr "" # type: Plain text #: usr_20.txt:45 msgid "" "Now you can press directly. You don't have to move the cursor to " "the end of the line before executing the command." msgstr "" # type: Plain text #: usr_20.txt:47 msgid "The most often used keys to move around in the command line:" msgstr "" # type: Plain text #: usr_20.txt:54 #, no-wrap msgid "" "\t\t\t\tone character left\n" "\t\t\t\tone character right\n" "\t or \tone word left\n" "\t or \tone word right\n" "\tCTRL-B or \tto begin of command line\n" "\tCTRL-E or \t\tto end of command line\n" msgstr "" # type: Plain text #: usr_20.txt:59 #, no-wrap msgid "" "\tNote:\n" "\t (cursor left key with Shift key pressed) and (cursor\n" "\tleft key with Control pressed) will not work on all keyboards. Same\n" "\tfor the other Shift and Control combinations.\n" msgstr "" # type: Plain text #: usr_20.txt:61 msgid "You can also use the mouse to move the cursor." msgstr "" # type: Plain text #: usr_20.txt:64 msgid "DELETING" msgstr "" # type: Plain text #: usr_20.txt:67 msgid "" "As mentioned, deletes the character before the cursor. To delete a " "whole word use CTRL-W." msgstr "" # type: Plain text #: usr_20.txt:69 usr_20.txt:83 #, no-wrap msgid "\t/the fine pig ~\n" msgstr "" # type: Plain text #: usr_20.txt:71 #, no-wrap msgid "\t\t CTRL-W\n" msgstr "" # type: Plain text #: usr_20.txt:73 #, no-wrap msgid "\t/the fine ~\n" msgstr "" # type: Plain text #: usr_20.txt:75 msgid "CTRL-U removes all text, thus allows you to start all over again." msgstr "" # type: Plain text #: usr_20.txt:78 msgid "OVERSTRIKE" msgstr "" # type: Plain text #: usr_20.txt:81 msgid "" "The key toggles between inserting characters and replacing the " "existing ones. Start with this text:" msgstr "" # type: Plain text #: usr_20.txt:87 msgid "" "Move the cursor to the start of \"fine\" with twice (or " "eight times, if doesn't work). Now press to switch to " "overstrike and type \"great\":" msgstr "" # type: Plain text #: usr_20.txt:89 #, no-wrap msgid "\t/the greatpig ~\n" msgstr "" # type: Plain text #: usr_20.txt:93 msgid "" "Oops, we lost the space. Now, don't use , because it would delete the " "\"t\" (this is different from Replace mode). Instead, press to " "switch from overstrike to inserting, and type the space:" msgstr "" # type: Plain text #: usr_20.txt:95 #, no-wrap msgid "\t/the great pig ~\n" msgstr "" # type: Plain text #: usr_20.txt:98 msgid "CANCELLING" msgstr "" # type: Plain text #: usr_20.txt:101 msgid "" "You thought of executing a : or / command, but changed your mind. To get " "rid of what you already typed, without executing it, press CTRL-C or ." msgstr "" # type: Plain text #: usr_20.txt:109 #, no-wrap msgid "" "\tNote:\n" "\t is the universal \"get out\" key. Unfortunately, in the good old\n" "\tVi pressing in a command line executed the command! Since that\n" "\tmight be considered to be a bug, Vim uses to cancel the command.\n" "\tBut with the 'cpoptions' option it can be made Vi compatible. And\n" "\twhen using a mapping (which might be written for Vi) also works\n" "\tVi compatible. Therefore, using CTRL-C is a method that always works.\n" msgstr "" # type: Plain text #: usr_20.txt:112 msgid "" "If you are at the start of the command line, pressing will cancel the " "command. It's like deleting the \":\" or \"/\" that the line starts with." msgstr "" # type: Plain text #: usr_20.txt:115 #, no-wrap msgid "*20.2*\tCommand line abbreviations\n" msgstr "" # type: Plain text #: usr_20.txt:119 msgid "" "Some of the \":\" commands are really long. We already mentioned that " "\":substitute\" can be abbreviated to \":s\". This is a generic mechanism, " "all \":\" commands can be abbreviated." msgstr "" # type: Plain text #: usr_20.txt:127 #, no-wrap msgid "" "How short can a command get? There are 26 letters, and many more " "commands.\n" "For example, \":set\" also starts with \":s\", but \":s\" doesn't start a " "\":set\"\n" "command. Instead \":set\" can be abbreviated to \":se\".\n" " When the shorter form of a command could be used for two commands, it\n" "stands for only one of them. There is no logic behind which one, you have " "to\n" "learn them. In the help files the shortest form that works is mentioned. " "For\n" "example: >\n" msgstr "" # type: Plain text #: usr_20.txt:129 #, no-wrap msgid "\t:s[ubstitute]\n" msgstr "" # type: Plain text #: usr_20.txt:132 msgid "" "This means that the shortest form of \":substitute\" is \":s\". The " "following characters are optional. Thus \":su\" and \":sub\" also work." msgstr "" # type: Plain text #: usr_20.txt:138 msgid "" "In the user manual we will either use the full name of command, or a short " "version that is still readable. For example, \":function\" can be " "abbreviated to \":fu\". But since most people don't understand what that " "stands for, we will use \":fun\". (Vim doesn't have a \":funny\" command, " "otherwise \":fun\" would be confusing too.)" msgstr "" # type: Plain text #: usr_20.txt:144 #, no-wrap msgid "" "It is recommended that in Vim scripts you write the full command name. " "That\n" "makes it easier to read back when you make later changes. Except for some\n" "often used commands like \":w\" (\":write\") and \":r\" (\":read\").\n" " A particularly confusing one is \":end\", which could stand for " "\":endif\",\n" "\":endwhile\" or \":endfunction\". Therefore, always use the full name.\n" msgstr "" # type: Plain text #: usr_20.txt:147 msgid "SHORT OPTION NAMES" msgstr "" # type: Plain text #: usr_20.txt:152 msgid "" "In the user manual the long version of the option names is used. Many " "options also have a short name. Unlike \":\" commands, there is only one " "short name that works. For example, the short name of 'autoindent' is " "'ai'. Thus these two commands do the same thing: >" msgstr "" # type: Plain text #: usr_20.txt:155 #, no-wrap msgid "" "\t:set autoindent\n" "\t:set ai\n" msgstr "" # type: Plain text #: usr_20.txt:157 msgid "You can find the full list of long and short names here: |option-list|." msgstr "" # type: Plain text #: usr_20.txt:160 #, no-wrap msgid "*20.3*\tCommand line completion\n" msgstr "" # type: Plain text #: usr_20.txt:163 msgid "" "This is one of those Vim features that, by itself, is a reason to switch " "from Vi to Vim. Once you have used this, you can't do without." msgstr "" # type: Plain text #: usr_20.txt:165 msgid "Suppose you have a directory that contains these files:" msgstr "" # type: Plain text #: usr_20.txt:169 #, no-wrap msgid "" "\tinfo.txt\n" "\tintro.txt\n" "\tbodyofthepaper.txt\n" msgstr "" # type: Plain text #: usr_20.txt:171 msgid "To edit the last one, you use the command: >" msgstr "" # type: Plain text #: usr_20.txt:173 #, no-wrap msgid "\t:edit bodyofthepaper.txt\n" msgstr "" # type: Plain text #: usr_20.txt:175 msgid "It's easy to type this wrong. A much quicker way is: >" msgstr "" # type: Plain text #: usr_20.txt:177 #, no-wrap msgid "\t:edit b\n" msgstr "" # type: Plain text #: usr_20.txt:182 msgid "" "Which will result in the same command. What happened? The key does " "completion of the word before the cursor. In this case \"b\". Vim looks in " "the directory and finds only one file that starts with a \"b\". That must " "be the one you are looking for, thus Vim completes the file name for you." msgstr "" # type: Plain text #: usr_20.txt:184 msgid "Now type: >" msgstr "" # type: Plain text #: usr_20.txt:186 #, no-wrap msgid "\t:edit i\n" msgstr "" # type: Plain text #: usr_20.txt:188 msgid "Vim will beep, and give you: >" msgstr "" # type: Plain text #: usr_20.txt:190 #, no-wrap msgid "\t:edit info.txt\n" msgstr "" # type: Plain text #: usr_20.txt:193 msgid "" "The beep means that Vim has found more than one match. It then uses the " "first match it found (alphabetically). If you press again, you get: >" msgstr "" # type: Plain text #: usr_20.txt:195 #, no-wrap msgid "\t:edit intro.txt\n" msgstr "" # type: Plain text #: usr_20.txt:200 #, no-wrap msgid "" "Thus, if the first doesn't give you the file you were looking for, " "press\n" "it again. If there are more matches, you will see them all, one at a " "time.\n" " If you press on the last matching entry, you will go back to what " "you\n" "first typed: >\n" msgstr "" # type: Plain text #: usr_20.txt:202 #, no-wrap msgid "\t:edit i\n" msgstr "" # type: Plain text #: usr_20.txt:205 msgid "" "Then it starts all over again. Thus Vim cycles through the list of " "matches. Use CTRL-P to go through the list in the other direction:" msgstr "" # type: Plain text #: usr_20.txt:213 #, no-wrap msgid "" "\t <------------------- -------------------------+\n" "\t\t\t\t\t\t\t\t |\n" "\t\t -->\t\t -->\n" "\t:edit i\t\t :edit info.txt\t\t :edit intro.txt\n" "\t\t <-- CTRL-P\t\t <-- CTRL-P\n" "\t |\n" "\t +---------------------- CTRL-P ------------------------>\n" msgstr "" # type: Plain text #: usr_20.txt:216 msgid "CONTEXT" msgstr "" # type: Plain text #: usr_20.txt:218 msgid "When you type \":set i\" instead of \":edit i\" and press you get: >" msgstr "" # type: Plain text #: usr_20.txt:220 #, no-wrap msgid "\t:set icon\n" msgstr "" # type: Plain text #: usr_20.txt:227 #, no-wrap msgid "" "Hey, why didn't you get \":set info.txt\"? That's because Vim has context\n" "sensitive completion. The kind of words Vim will look for depends on the\n" "command before it. Vim knows that you cannot use a file name just after a\n" "\":set\" command, but you can use an option name.\n" " Again, if you repeat typing the , Vim will cycle through all " "matches.\n" "There are quite a few, it's better to type more characters first: >\n" msgstr "" # type: Plain text #: usr_20.txt:229 #, no-wrap msgid "\t:set isk\n" msgstr "" # type: Plain text #: usr_20.txt:231 msgid "Gives: >" msgstr "" # type: Plain text #: usr_20.txt:233 #, no-wrap msgid "\t:set iskeyword\n" msgstr "" # type: Plain text #: usr_20.txt:235 msgid "Now type \"=\" and press : >" msgstr "" # type: Plain text #: usr_20.txt:237 #, no-wrap msgid "\t:set iskeyword=@,48-57,_,192-255\n" msgstr "" # type: Plain text #: usr_20.txt:245 #, no-wrap msgid "" "What happens here is that Vim inserts the old value of the option. Now " "you\n" "can edit it.\n" " What is completed with is what Vim expects in that place. Just " "try\n" "it out to see how it works. In some situations you will not get what you\n" "want. That's either because Vim doesn't know what you want, or because\n" "completion was not implemented for that situation. In that case you will " "get\n" "a inserted (displayed as ^I).\n" msgstr "" # type: Plain text #: usr_20.txt:248 msgid "LIST MATCHES" msgstr "" # type: Plain text #: usr_20.txt:251 msgid "" "When there are many matches, you would like to see an overview. Do this by " "pressing CTRL-D. For example, pressing CTRL-D after: >" msgstr "" # type: Plain text #: usr_20.txt:253 #, no-wrap msgid "\t:set is\n" msgstr "" # type: Plain text #: usr_20.txt:255 msgid "results in: >" msgstr "" # type: Plain text #: usr_20.txt:259 #, no-wrap msgid "" "\t:set is\n" "\tincsearch isfname isident iskeyword isprint\n" "\t:set is\n" msgstr "" # type: Plain text #: usr_20.txt:269 #, no-wrap msgid "" "Vim lists the matches and then comes back with the text you typed. You " "can\n" "now check the list for the item you wanted. If it isn't there, you can " "use\n" " to correct the word. If there are many matches, type a few more\n" "characters before pressing to complete the rest.\n" " If you have watched carefully, you will have noticed that \"incsearch\"\n" "doesn't start with \"is\". In this case \"is\" stands for the short name " "of\n" "\"incsearch\". (Many options have a short and a long name.) Vim is " "clever\n" "enough to know that you might have wanted to expand the short name of the\n" "option into the long name.\n" msgstr "" # type: Plain text #: usr_20.txt:272 msgid "THERE IS MORE" msgstr "" # type: Plain text #: usr_20.txt:276 msgid "" "The CTRL-L command completes the word to the longest unambiguous string. If " "you type \":edit i\" and there are files \"info.txt\" and " "\"info_backup.txt\" you will get \":edit info\"." msgstr "" # type: Plain text #: usr_20.txt:282 msgid "" "The 'wildmode' option can be used to change the way completion works. The " "'wildmenu' option can be used to get a menu-like list of matches. Use the " "'suffixes' option to specify files that are less important and appear at the " "end of the list of files. The 'wildignore' option specifies files that are " "not listed at all." msgstr "" # type: Plain text #: usr_20.txt:284 msgid "More about all of this here: |cmdline-completion|" msgstr "" # type: Plain text #: usr_20.txt:287 #, no-wrap msgid "*20.4*\tCommand line history\n" msgstr "" # type: Plain text #: usr_20.txt:291 msgid "" "In chapter 3 we briefly mentioned the history. The basics are that you can " "use the key to recall an older command line. then takes you " "back to newer commands." msgstr "" # type: Plain text #: usr_20.txt:297 msgid "" "There are actually four histories. The ones we will mention here are for " "\":\" commands and for \"/\" and \"?\" search commands. The \"/\" and \"?\" " "commands share the same history, because they are both search commands. The " "two other histories are for expressions and input lines for the input() " "function. |cmdline-history|" msgstr "" # type: Plain text #: usr_20.txt:301 msgid "" "Suppose you have done a \":set\" command, typed ten more colon commands and " "then want to repeat that \":set\" command again. You could press \":\" and " "then ten times . There is a quicker way: >" msgstr "" # type: Plain text #: usr_20.txt:303 #, no-wrap msgid "\t:se\n" msgstr "" # type: Plain text #: usr_20.txt:308 msgid "" "Vim will now go back to the previous command that started with \"se\". You " "have a good chance that this is the \":set\" command you were looking for. " "At least you should not have to press very often (unless \":set\" " "commands is all you have done)." msgstr "" # type: Plain text #: usr_20.txt:313 #, no-wrap msgid "" "The key will use the text typed so far and compare it with the lines " "in\n" "the history. Only matching lines will be used.\n" " If you do not find the line you were looking for, use to go back " "to\n" "what you typed and correct that. Or use CTRL-U to start all over again.\n" msgstr "" # type: Plain text #: usr_20.txt:315 msgid "To see all the lines in the history: >" msgstr "" # type: Plain text #: usr_20.txt:317 #, no-wrap msgid "\t:history\n" msgstr "" # type: Plain text #: usr_20.txt:320 msgid "" "That's the history of \":\" commands. The search history is displayed with " "this command: >" msgstr "" # type: Plain text #: usr_20.txt:322 #, no-wrap msgid "\t:history /\n" msgstr "" # type: Plain text #: usr_20.txt:326 msgid "" "CTRL-P will work like , except that it doesn't matter what you already " "typed. Similarly for CTRL-N and . CTRL-P stands for previous, CTRL-N " "for next." msgstr "" # type: Plain text #: usr_20.txt:329 #, no-wrap msgid "*20.5*\tCommand line window\n" msgstr "" # type: Plain text #: usr_20.txt:334 msgid "" "Typing the text in the command line works different from typing text in " "Insert mode. It doesn't allow many commands to change the text. For most " "commands that's OK, but sometimes you have to type a complicated command. " "That's where the command line window is useful." msgstr "" # type: Plain text #: usr_20.txt:336 msgid "Open the command line window with this command: >" msgstr "" # type: Plain text #: usr_20.txt:338 #, no-wrap msgid "\tq:\n" msgstr "" # type: Plain text #: usr_20.txt:341 msgid "" "Vim now opens a (small) window at the bottom. It contains the command line " "history, and an empty line at the end:" msgstr "" # type: Plain text #: usr_20.txt:356 #, no-wrap msgid "" "\t+-------------------------------------+\n" "\t|other window\t\t\t |\n" "\t|~\t\t\t\t |\n" "\t|file.txt=============================|\n" "\t|:e c\t\t\t\t |\n" "\t|:e config.h.in\t\t\t |\n" "\t|:set path=.,/usr/include,,\t |\n" "\t|:set iskeyword=@,48-57,_,192-255 |\n" "\t|:set is\t\t\t |\n" "\t|:q\t\t\t\t |\n" "\t|:\t\t\t\t |\n" "\t|command-line=========================|\n" "\t|\t\t\t\t |\n" "\t+-------------------------------------+\n" msgstr "" # type: Plain text #: usr_20.txt:360 msgid "" "You are now in Normal mode. You can use the \"hjkl\" keys to move around. " "For example, move up with \"5k\" to the \":e config.h.in\" line. Type " "\"$h\" to go to the \"i\" of \"in\" and type \"cwout\". Now you have " "changed the line to:" msgstr "" # type: Plain text #: usr_20.txt:362 #, no-wrap msgid "\t:e config.h.out ~\n" msgstr "" # type: Plain text #: usr_20.txt:370 #, no-wrap msgid "" "Now press and this command will be executed. The command line " "window\n" "will close.\n" " The command will execute the line under the cursor. It doesn't\n" "matter whether Vim is in Insert mode or in Normal mode.\n" " Changes in the command line window are lost. They do not result in the\n" "history to be changed. Except that the command you execute will be added " "to\n" "the end of the history, like with all executed commands.\n" msgstr "" # type: Plain text #: usr_20.txt:379 #, no-wrap msgid "" "The command line window is very useful when you want to have overview of " "the\n" "history, lookup a similar command, change it a bit and execute it. A " "search\n" "command can be used to find something.\n" " In the previous example the \"?config\" search command could have been " "used\n" "to find the previous command that contains \"config\". It's a bit " "strange,\n" "because you are using a command line to search in the command line window.\n" "While typing that search command you can't open another command line " "window,\n" "there can be only one.\n" msgstr "" # type: Plain text #: usr_20.txt:383 msgid "Next chapter: |usr_21.txt| Go away and come back" msgstr "" # type: Plain text #: usr_20.txt:384 msgid "Copyright: see |manual-copyright| vim:tw=78:ts=8:ft=help:norl:" msgstr ""