├── CODE_OF_CONDUCT.md ├── LICENSE ├── README.md ├── README_NOTE.md └── Vimtutor.txt /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | * Using welcoming and inclusive language 12 | * Being respectful of differing viewpoints and experiences 13 | * Gracefully accepting constructive criticism 14 | * Focusing on what is best for the community 15 | * Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | * The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | * Trolling, insulting/derogatory comments, and personal or political attacks 21 | * Public or private harassment 22 | * Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | * Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at hanielxx@outlook.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | {one line to give the program's name and a brief idea of what it does.} 635 | Copyright (C) {year} {name of author} 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | {project} Copyright (C) {year} {fullname} 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # VimTutor 2 | 3 | [VimTutor-note][note] | [Vim on git][vim] | [Vim-galore][galore] | [Vim][vimorg] | [SpaceVim][SpaceVim] | [Hack SpaceVim][hackspvim] 4 | 5 | 感觉vimtutor是众多vim帮助文档中最好的入门教程,其中的每一个知识点都有相应
6 | 的习题,可以让你在短时间内掌握基本的VIM操作。 7 | 8 | 想要入门vim的童鞋最好还是一边看文档,一边用vim自己尝试每个命令。 9 | 10 | **请通过vim练习:vim Vimtutor.txt** 11 | 12 | \=============================================================================== 13 | ## W e l c o m e t o t h e V I M T u t o r - Version 1.7 14 | ## 欢迎使用VIM教程 1.7版 15 | \=============================================================================== 16 | 17 | Vim is a very powerful editor that has many commands, too many to 18 | explain in a tutor such as this. This tutor is designed to describe 19 | enough of the commands that you will be able to easily use Vim as 20 | an all-purpose editor.
21 | 22 | VIM是一个强大的编辑器,它拥有大量的命令,不可能在本教程中全部解释。但是,本
23 | 教程描述了足够多的命令,使你能轻松将VIM作为通用编辑器。 24 | 25 | The approximate time required to complete the tutor is 25-30 minutes,
26 | depending upon how much time is spent with experimentation.
27 | 28 | 完成本教程的时间大约是25-30分钟,主要依赖于你在实验中花去的时间。 29 | 30 | ATTENTION: 31 | The commands in the lessons will modify the text. Make a copy of this 32 | file to practise on (if you started "vimtutor" this is already a copy).
33 | 34 | **注意**: 35 | 本课程中的命令会改变本文的内容,请创建一个副本来练习(如果你用命令“vimtutor"
36 | 开始,本文已经是自动生成的副本了)。
37 | 38 | 注:创建副本的命令为: 39 | `vim -u NONE -c 'e $VIMRUNTIME/tutor/tutor' -c 'w! vimtutor_copy' -c 'q';ls -l` 40 | 41 | It is important to remember that this tutor is set up to teach by 42 | use. That means that you need to execute the commands to learn them 43 | properly. If you only read the text, you will forget the commands!
44 | 很重要的一点是,要记住,本教程是用于指导VIM的使用。这意味着你需要执行命令 45 | 以正确地学习它们。如果你只是单纯阅读本文,你会很快忘记这些命令! 46 | 47 | Now, make sure that your Shift-Lock key is NOT depressed and press 48 | the j key enough times to move the cursor so that Lesson 1.1 49 | completely fills the screen.
50 | 现在,请确保你的shift键是启用的,多次按 j 键移动到1.1课,使之 51 | 居于屏幕中心。 52 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 53 | ## Lesson 1.1: MOVING THE CURSOR 54 | ## 1.1课:移动光标 55 | 56 | **To move the cursor, press the h,j,k,l keys as indicated.**
57 | **要移动光标,则按示意按下 h,j,k,l 键** 58 | ``` 59 | ^ 60 | k Hint: The h key is at the left and moves left. 61 | < h l > The l key is at the right and moves right. 62 | j The j key looks like a down arrow. 63 | v 64 | ``` 65 | **示意**: 66 | -左边的h键是往左移 67 | -右边的l键是往右移 68 | -j键是往下移 69 | 1. Move the cursor around the screen until you are comfortable.
70 | 在屏幕中移动光标到你觉得合适的地方。 71 | 72 | 2. Hold down the down key (j) until it repeats. 73 | Now you know how to move to the next lesson.
74 | 按住j键,使之重复作用。 75 | 现在你知道了怎么移动到下一节了吧。 76 | 77 | 3. Using the down key, move to Lesson 1.2.
78 | 使用下移键,移动到1.2节。 79 | 80 | **NOTE**: If you are ever unsure about something you typed, press to place 81 | you in Normal mode. Then retype the command you wanted.
82 | **注意**:如意你不确定你按下了什么,按回到正常模式。再按你想要输入的命令。 83 | 84 | **NOTE**: The cursor keys should also work. But using hjkl you will be able to 85 | move around much faster, once you get used to it. Really!
86 | **注意**:光标键同样生效。但hjkl键会使你移动得更快,只要你熟悉了它。真的! 87 | 88 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 89 | ## Lesson 1.2: EXITING VIM 90 | ## 1.2节:退出VIM 91 | 92 | !! **NOTE:** Before executing any of the steps below, read this entire lesson!!
93 | !! **注**:执行以下步骤前,请读完全节!! 94 | 95 | 1. Press the key (to make sure you are in Normal mode).
96 | 按下键(确保你处于正常模式)。 97 | 98 | 2. Type: :q! . 99 | This exits the editor, DISCARDING any changes you have made.
100 | 按: :q! . 101 | 此命令使编辑器退出并放弃你作的作用改动。(即不保存对文本的编辑) 102 | 103 | 3. When you see the shell prompt, type the command that got you into this 104 | tutor. That would be: vimtutor
105 | 当你看见shell提示时,输入以下命令并进入本教程:vimtutor 106 | 注:事实上你vimtutor是打开一个副本,你也可以打开你之前创建的副本: 107 | vim vimtutor_copy 108 | 109 | 4. If you have these steps memorized and are confident, execute steps 110 | 1 through 3 to exit and re-enter the editor.
111 | 如果你已经记住的这些步骤并有信心了,就执行步骤1-3退出,然后再进入编辑器。 112 | 113 | **NOTE**: :q! discards any changes you made. In a few lessons you 114 | will learn how to save the changes to a file.
115 | **注**:q! 会取消你对文本所作的任何改动。在新的一节你会学到保存文件的修改。 116 | 117 | 5. Move the cursor down to Lesson 1.3.
118 | 移动光标到1.3节。 119 | 120 | 121 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 122 | ## Lesson 1.3: TEXT EDITING - DELETION 123 | ## 1.3节:文本编辑之删除 124 | 125 | 126 | **Press x to delete the character under the cursor.**
127 | **按下x键以删除光标所在的字符.** 128 | 129 | 1. Move the cursor to the line below marked --->.
130 | 移动光标到--->标记的行。 131 | 132 | 2. To fix the errors, move the cursor until it is on top of the 133 | character to be deleted.
134 | 为了修复错误,移动光标到要删除字符上。 135 | 136 | 3. Press the x key to delete the unwanted character.
137 | 按下x键以删除不想要的字符。 138 | 139 | 4. Repeat steps 2 through 4 until the sentence is correct.
140 | 重复步骤2到4,直到语句正确。 141 | 142 | ---> The ccow jumpedd ovverr thhe mooon. 143 | 144 | 5. Now that the line is correct, go on to Lesson 1.4.
145 | 现在语句正确了吧,请移步1.4节。 146 | 147 | NOTE: As you go through this tutor, do not try to memorize, learn by usage.
148 | 注:浏览本教程时,不要试着去记,而是学习其用法。 149 | 150 | 151 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 152 | ## Lesson 1.4: TEXT EDITING - INSERTION 153 | ## 1.4节:文本编辑之插入 154 | 155 | 156 | **Press i to insert text.**
157 | **按下 i键 以插入文本**
158 | 159 | 1. Move the cursor to the first line below marked --->.
160 | 移动光标到--->标记的行。 161 | 162 | 2. To make the first line the same as the second, move the cursor on top 163 | of the first character AFTER where the text is to be inserted.
164 | 为使第一行同第二行相同,移动光标到要插入文本处字符上。 165 | 166 | 3. Press i and type in the necessary additions.
167 | 按下i键,键入需要的字符。 168 | 169 | 4. As each error is fixed press to return to Normal mode. 170 | Repeat steps 2 through 4 to correct the sentence.
171 | 当错误被修复后,按下回到正常模式。重复步骤2到4以修改完整。 172 | 173 | ---> There is text misng this . 174 | ---> There is some text missing from this line. 175 | 176 | 5. When you are comfortable inserting text move to lesson 1.5.
177 | 当你正确插入完文本后,移步1.5节。 178 | 179 | 180 | 181 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 182 | ## Lesson 1.5: TEXT EDITING - APPENDING 183 | ## 1.5节:文本编辑之追加 184 | 185 | 186 | **Press A to append text.**
187 | **按下A键以追加文本** 188 | 189 | 1. Move the cursor to the first line below marked --->. 190 | It does not matter on what character the cursor is in that line.
191 | 移动光标到--->标记的行。 192 | 该行同下一行在字符上不匹配。 193 | 194 | 2. Press A and type in the necessary additions.
195 | 按下A键,然后键入要添加的内容。 196 | 197 | 3. As the text has been appended press to return to Normal mode.
198 | 当添加完文本后按下\,返回到正常模式。 199 | 200 | 4. Move the cursor to the second line marked ---> and repeat 201 | steps 2 and 3 to correct this sentence.
202 | 移动光标到第二个--->标记的行。 203 | 204 | ---> There is some text missing from th 205 | There is some text missing from this line. 206 | ---> There is also some text miss 207 | There is also some text missing here. 208 | 209 | 5. When you are comfortable appending text move to lesson 1.6.
210 | 当你正确添加了文本后,请移步1.6节。 211 | 212 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 213 | ## Lesson 1.6: EDITING A FILE 214 | ## 1.6节:编辑一个文件 215 | 216 | **Use :wq to save a file and exit.**
217 | **:wq 保存文件并退出** 218 | 219 | !! NOTE: Before executing any of the steps below, read this entire lesson!!
220 | !! 注: 执行以下步骤之前,请读完全节!! 221 | 222 | 1. Exit this tutor as you did in lesson 1.2: :q! 223 | Or, if you have access to another terminal, do the following there.
224 | 像1.2节一样,退出本教程: :q! 225 | 或者,你也可以访问其它的终端,并执行以下几步。 226 | 227 | 2. At the shell prompt type this command: vim tutor 228 | 'vim' is the command to start the Vim editor, 'tutor' is the name of the 229 | file you wish to edit. Use a file that may be changed.
230 | 在shell提示符下,键入此命令: vim tutor 231 | 'vim' 是要启动的vim编辑器,‘tutor'是编辑的文件名。该文件将被编辑修改。 232 | 233 | 3. Insert and delete text as you learned in the previous lessons.
234 | 按照你在前几节你所学到的插入、删除文本。 235 | 236 | 4. Save the file with changes and exit Vim with: :wq
237 | 保存对文件的修改,并退出vim: :wq 238 | 239 | 5. If you have quit vimtutor in step 1 restart the vimtutor and move down to 240 | the following summary.
241 | 如果你在步骤1中退出了本教程,启动本教程并移步到以的总结。 242 | 243 | 6. After reading the above steps and understanding them: do it.
244 | 阅读完以下几步后,理解并执行它们。 245 | 246 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 247 | ## Lesson 1 SUMMARY 248 | ## 课程1 的 总结 249 | 250 | 251 | 1. The cursor is moved using either the arrow keys or the hjkl keys. 252 | h (left) j (down) k (up) l (right)
253 | 可以使用光标键或者hjkl键移动光标 254 | h (左移) j (下移) k (上移) l (右移) 255 | 256 | 2. To start Vim from the shell prompt type: vim FILENAME
257 | 从shell提示符启动VIM,请键入:vim FILENAME \ 258 | 259 | 3. To exit Vim type: \ :q! \ to trash all changes. 260 | OR type: \ :wq \ to save the changes.
261 | 262 | 要退出VIM: \ :q! \ 放弃所有修改。 263 | 或者键入: \ :wq \ 保存所有的修改。 264 | 265 | 4. To delete the character at the cursor type: x
266 | 删除光标处的一个字符: x 267 | 268 | 5. To insert or append text type: 269 | i type inserted text \ insert before the cursor 270 | A type appended text \ append after the line
271 | 插入或者追加文本: 272 | i type inserted text \ 插入文本 273 | A type appended text \ 追加文本 274 | 275 | NOTE: Pressing \ will place you in Normal mode or will cancel 276 | \ an unwanted and partially completed command.
277 | 注: 按下\ 会回到正常模式,或者取消未完成的命令。 278 | 279 | Now continue with Lesson 2.
280 | 现在继续进行第2课。 281 | 282 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 283 | ## Lesson 2.1: DELETION COMMANDS 284 | ## 2.1节:删除命令 285 | 286 | 287 | **Type dw to delete a word.**
288 | **键入 dw 以删除一个单词.** 289 | 290 | 1. Press \ to make sure you are in Normal mode.
291 | 按下 \ 以确保你处于正常模式。 292 | 293 | 2. Move the cursor to the line below marked --->.
294 | 移动光标到以下以--->标记的行。 295 | 296 | 3. Move the cursor to the beginning of a word that needs to be deleted.
297 | 移动光标到需要删除的单词头。 298 | 299 | 4. Type dw to make the word disappear.
300 | 键入 dw 以使该单词消失(被删除)。 301 | 302 | NOTE: The letter d will appear on the last line of the screen as you type 303 | it. Vim is waiting for you to type w . If you see another character 304 | than d you typed something wrong; press \ and start over.
305 | 注: 当你键入d时,字d 会在屏幕最低处显示,此时VIM在等待你键入w。 当你错误的键入时,你会看见其它的字符而非d;按下 \ 重新开始。 306 | 307 | ---> There are a some words fun that don't belong paper in this sentence. 308 | 309 | 5. Repeat steps 3 and 4 until the sentence is correct and go to Lesson 2.2.
310 | 重新步骤3到4,直到语句正确,然后移步2.2节。 311 | 312 | 313 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 314 | ## Lesson 2.2: MORE DELETION COMMANDS 315 | ## 2.2节:其它的删除命令 316 | 317 | 318 | **Type d$ to delete to the end of the line.**
319 | **键入 d$ 以删除光标到行尾间处的字符** 320 | 321 | 1. Press \ to make sure you are in Normal mode.
322 | 按下 \ 以确保你处于正常模式。 323 | 324 | 2. Move the cursor to the line below marked --->.
325 | 移动光标到以下以--->标记的行。 326 | 327 | 3. Move the cursor to the end of the correct line (AFTER the first . ).
328 | 移动光标到正确行的末端(在第一个.号后)。 329 | 330 | 4. Type d$ to delete to the end of the line.
331 | 键入 d$ 以删除到行尾。 332 | 333 | ---> Somebody typed the end of this line twice. end of this line twice. 334 | 335 | 336 | 5. Move on to Lesson 2.3 to understand what is happening.
337 | 移动到2.3节,并理解发生了什么。 338 | 339 | 340 | 341 | 342 | 343 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 344 | ## Lesson 2.3: ON OPERATORS AND MOTIONS 345 | ## 2.3节:关于操作码和对象 346 | (operator我理解为操作码,motions我理解为对象) 347 | 348 | 349 | Many commands that change text are made from an operator and a motion. 350 | The format for a delete command with the d delete operator is as follows: 351 | 352 | d motion 353 | 354 | Where: 355 | d - is the delete operator. 356 | motion - is what the operator will operate on (listed below). 357 | 358 | A short list of motions: 359 | w - until the start of the next word, EXCLUDING its first character. 360 | e - to the end of the current word, INCLUDING the last character. 361 | $ - to the end of the line, INCLUDING the last character. 362 | 363 | Thus typing de will delete from the cursor to the end of the word. 364 | 365 | NOTE: Pressing just the motion while in Normal mode without an operator will 366 | move the cursor as specified.
367 | 许多修改文本的命令由两部分组成:操作码和对象。 368 | 删除命令d的格式如下: 369 | 370 | d 对象 371 | 其中: 372 | d -是操作码 373 | motlion -是操作码要操作的对象(译者:更确切地说应是范围吧?)(罗列在下方) 374 | 关于对象的小清单: 375 | w -到下一个单词头,除开所在的第一个字符。 376 | e -到下一个单词尾,包括所在单词的最后一个字符。 377 | $- 到行尾,包括了最后一个字符。 378 | 0- 到行首,包含空格。 379 | ^ -到行首,不含空格。 380 | G -到文本最后一行首 381 | gg -到文本首行。 382 | 所以de会删除光标处到单词尾下的字符。 383 | 384 | 注: 不带操作码按下对象键时,仅会按对象指定的方式 移动光标。 385 | 386 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 387 | ## Lesson 2.4: USING A COUNT FOR A MOTION 388 | ## 2.4节:对对象使用计数 389 | 390 | **Typing a number before a motion repeats it that many times.** 391 | 392 | 1. Move the cursor to the start of the line marked ---> below. 393 | 394 | 2. Type 2w to move the cursor two words forward. 395 | 396 | 3. Type 3e to move the cursor to the end of the third word forward. 397 | 398 | 4. Type 0 (zero) to move to the start of the line. 399 | 400 | 5. Repeat steps 2 and 3 with different numbers. 401 | 402 | ---> This is just a line with words you can move around in. 403 | 404 | 6. Move on to Lesson 2.5.
405 | 406 | **在对象前键入重复的次数.**
407 | 408 | 1. 移动光标到以下以--->标记的行。 409 | 410 | 2. 键入 2w 以使光标向后移动两个单词。 411 | 412 | 3. 键入 3e 以使光标向后移动到第三个单词尾。 413 | 414 | 4. 键入 0 移动到行首。 415 | 416 | 5. 使用不同 的数字重复步骤2到3. 417 | 418 | ---> This is just a line with words you can move around in.
419 | 420 | 6. 移步到2.5节。 421 | 422 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 423 | ## Lesson 2.5: USING A COUNT TO DELETE MORE 424 | ## 2.5节:使用计数以删除得更多 425 | 426 | 427 | **Typing a number with an operator repeats it that many times.**
428 | **为操作码键入 一个数字,使之重复多次.** 429 | 430 | In the combination of the delete operator and a motion mentioned above you 431 | insert a count before the motion to delete more: 432 | d number motion
433 | 434 | 合并上文提到的删除操作码和对象,在对象前插入一个数字以删除更多 435 | d 数字 对象 436 | 437 | 1. Move the cursor to the first UPPER CASE word in the line marked --->.
438 | 移动光标到以下以--->标记的行的第一个大写单词处。 439 | 440 | 2. Type d2w to delete the two UPPER CASE words
441 | 键入 d2w 以删除2个大写 单词。 442 | 443 | 3. Repeat steps 1 and 2 with a different count to delete the consecutive 444 | UPPER CASE words with one command
445 | 用不同的计数重复步骤1和2,以一个命令删除多个连续的大写单词。 446 | 447 | ---> this ABC DE line FGHI JK LMN OP of words is Q RS TUV cleaned up. 448 | 449 | 450 | 451 | 452 | 453 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 454 | ## Lesson 2.6: OPERATING ON LINES 455 | ## 2.6节:行的操作 456 | 457 | 458 | **Type dd to delete a whole line.**
459 | **键入 dd 以删除一整行.** 460 | 461 | Due to the frequency of whole line deletion, the designers of Vi decided 462 | it would be easier to simply type two d's to delete a line.
463 | 由于需要频繁的删除一整行,vi的设计者决定通过简单的键入两d轻松删除一整行。 464 | 465 | 1. Move the cursor to the second line in the phrase below. 466 | 2. Type dd to delete the line. 467 | 3. Now move to the fourth line. 468 | 4. Type 2dd to delete two lines.
469 | 1. 移动移动到以以下短语的第二行。 470 | 2. 键入 dd 以删除行。 471 | 3. 现在移动到第四行。 472 | 4. 键入 2dd 以删除后两行。 473 | 474 | ---> 1) Roses are red, 475 | ---> 2) Mud is fun, 476 | ---> 3) Violets are blue, 477 | ---> 4) I have a car, 478 | ---> 5) Clocks tell time, 479 | ---> 6) Sugar is sweet 480 | ---> 7) And so are you. 481 | 482 | 483 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 484 | ## Lesson 2.7: THE UNDO COMMAND 485 | ## 2.7节:恢复命令 486 | 487 | 488 | **Press u to undo the last commands, U to fix a whole line.**
489 | **按下u 以恢复最后的命令,U 是修复一整行.** 490 | 491 | 1. Move the cursor to the line below marked ---> and place it on the 492 | first error. 493 | 2. Type x to delete the first unwanted character. 494 | 3. Now type u to undo the last command executed. 495 | 4. This time fix all the errors on the line using the x command. 496 | 5. Now type a capital U to return the line to its original state. 497 | 6. Now type u a few times to undo the U and preceding commands. 498 | 7. Now type CTRL-R (keeping CTRL key pressed while hitting R) a few times 499 | to redo the commands (undo the undo's).
500 | 1. 移动光标到以--->标记的行,定位到第一处错误。 501 | 2. 键入 x 以删除第一个不要的字符。 502 | 3. 现在 键入 u 以恢复最后执行的命令。 503 | 4. 这次用x命令修复该行的所有错误。 504 | 5. 现在键入一个大写的 U 以回到行的原始状态。 505 | 6.现在按几次 u 以恢复U 和之间的命令。 506 | 7. 现在 按几次 CTRL+R(按住CTRL同时敲击R),以撤消恢复命令(与u命令相反)。 507 | 508 | ---> Fiix the errors oon thhis line and reeplace them witth undo. 509 | 510 | 8. These are very useful commands. Now move on to the Lesson 2 Summary.
511 | 8. 这些都是非常有用的命令。现在移步到第2课的总结。 512 | 513 | 514 | 515 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 516 | ## Lesson 2 SUMMARY 517 | ## 第2课总结 518 | 519 | 520 | 1. To delete from the cursor up to the next word type: dw
521 | 删除光标到下一个单词: dw 522 | 2. To delete from the cursor to the end of a line type: d$
523 | 删除光标到行尾: d$ 524 | 3. To delete a whole line type: dd
525 | 删除整行: dd 526 | 527 | 4. To repeat a motion prepend it with a number: 2w
528 | 预置数字以重复对象: 2w 529 | 5. The format for a change command is: 530 | operator [number] motion 531 | where: 532 | operator - is what to do, such as d for delete 533 | [number] - is an optional count to repeat the motion 534 | motion - moves over the text to operate on, such as w (word), 535 | $ (to the end of line), etc
536 | 更改命令的格式: 537 | 操作码 [数字] 对象 538 | 539 | 6. To move to the start of the line use a zero: 0
540 | 用0移动到行首: 0 541 | 542 | 7. To undo previous actions, type: u (lowercase u) 543 | To undo all the changes on a line, type: U (capital U) 544 | To undo the undo's, type: CTRL-
545 | 恢复之前的动作,键入: u (小写) 546 | 恢复对一行的所有改变,键入:U(大写) 547 | 恢复恢复,键入: CTRL-R 548 | 549 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 550 | ## Lesson 3.1: THE PUT COMMAND 551 | ## 3.1节:PUT命令 552 | 553 | 554 | **Type p to put previously deleted text after the cursor.**
555 | **输入 p 以在光标处粘贴先前删除的文本.** 556 | 557 | 1. Move the cursor to the first ---> line below.
558 | 移动光标到以下以--->标记的行。 559 | 560 | 2. Type dd to delete the line and store it in a Vim register.
561 | 输入 dd 以删除该行,该行会被存储至VIM寄存器中。 562 | 563 | 3. Move the cursor to the c) line, ABOVE where the deleted line should go.
564 | 移动光标到c)行,即被删除行要到达的前行。 565 | 566 | 4. Type p to put the line below the cursor.
567 | 键入 p 将那行粘贴到光标之下。 568 | 569 | 5. Repeat steps 2 through 4 to put all the lines in correct order.
570 | 重复步骤2到4以粘贴所有的行到正确的位置。 571 | 572 | ---> d) Can you learn too? 573 | ---> b) Violets are blue, 574 | ---> c) Intelligence is learned, 575 | ---> a) Roses are red, 576 | 577 | 578 | 579 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 580 | ## Lesson 3.2: THE REPLACE COMMAND 581 | ## 3.2节:替换命令 582 | 583 | 584 | **Type rx to replace the character at the cursor with x .**
585 | **键入 rx 以替换光标处的字符** 586 | 587 | 1. Move the cursor to the first line below marked --->.
588 | 移动光标到以--->标记的行。 589 | 590 | 2. Move the cursor so that it is on top of the first error.
591 | 移动光标到第一个错误。 592 | 593 | 3. Type r and then the character which should be there.
594 | 键入 r和要更正的字符。 595 | 596 | 4. Repeat steps 2 and 3 until the first line is equal to the second one.
597 | 重复步骤2和3,直到一二行相同。 598 | 599 | ---> Whan this lime was tuoed in, someone presswd some wrojg keys! 600 | ---> When this line was typed in, someone pressed some wrong keys! 601 | 602 | 5. Now move on to Lesson 3.3.
603 | 现在移动到3.3节吧。 604 | 605 | NOTE: Remember that you should be learning by doing, not memorization.
606 | 注:记住你应该学会做而非记。 607 | 608 | 609 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 610 | ## Lesson 3.3: THE CHANGE OPERATOR 611 | ## 3.3:变更操作码 612 | 613 | 614 | **To change until the end of a word, type ce .**
615 | **要变更光标到词尾,键入:ce** 616 | 617 | 1. Move the cursor to the first line below marked --->.
618 | 移动光标到以--->标记的行。 619 | 620 | 2. Place the cursor on the u in lubw.
621 | 定位光标至 lubw 的 u 上。 622 | 623 | 3. Type ce and the correct word (in this case, type ine ).
624 | 键入 ce 和 正确的单词(本例中,应该键入 ceine). 625 | 626 | 4. Press \ and move to the next character that needs to be changed.
627 | 按\,并移动到下一个需要更改的字符。 628 | 629 | 5. Repeat steps 3 and 4 until the first sentence is the same as the second.
630 | 重复步骤3和4,以使第一句同第二句相同。 631 | 632 | ---> This lubw has a few wptfd that mrrf changing usf the change operator. 633 | ---> This line has a few words that need changing using the change operator. 634 | 635 | Notice that ce deletes the word and places you in Insert mode.
636 | 注意,ce 是删除单词并定位到插入模式(译者:其实后面的e就是对象,而前面的 c是操作码) 637 | 638 | 639 | 640 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 641 | ## Lesson 3.4: MORE CHANGES USING c 642 | ## 3.4节:其它的c更改命令 643 | 644 | 645 | **The change operator is used with the same motions as delete.**
646 | **同delete 命令一样,更改操作码也使用相同的对象。** 647 | 648 | 1. The change operator works in the same way as delete. The format is: 649 | 650 | c [number] motion
651 | 更改操作码的用法与删除操作码相同,格式为: 652 | c [number] motion 653 | 654 | 2. The motions are the same, such as w (word) and $ (end of line).
655 | 所有的对象是相同的,例如w(单词)、$(行尾)。 656 | 657 | 3. Move to the first line below marked --->.
658 | 移动到以下以--->标记的第一行。 659 | 660 | 4. Move the cursor to the first error.
661 | 移动光标到第一处错误。 662 | 663 | 5. Type c$ and type the rest of the line like the second and press \.
664 | 键入 c$ 和 余下的同第二行相同的字等符,并按下。 665 | 666 | ---> The end of this line needs some help to make it like the second. 667 | ---> The end of this line needs to be corrected using the c$ command. 668 | 669 | NOTE: You can use the Backspace key to correct mistakes while typing.
670 | 注: 在键入时,你可以使用退格以删除错误。 671 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 672 | ## Lesson 3 SUMMARY 673 | ## 第3课总结 674 | 675 | 676 | 1. To put back text that has just been deleted, type p . This puts the 677 | deleted text AFTER the cursor (if a line was deleted it will go on the 678 | line below the cursor).
679 | 要粘贴刚刚删除的文本,键入 p.这会把被删文本粘贴到光标之后(如果某行被删,它会被粘贴到光标之后的一行)。 680 | 681 | 2. To replace the character under the cursor, type r and then the 682 | character you want to have there.
683 | 要替换光标处的字符,键入 r 和要插入的字符。 684 | 685 | 3. The change operator allows you to change from the cursor to where the 686 | motion takes you. eg. Type ce to change from the cursor to the end of 687 | the word, c$ to change to the end of a line.
688 | 更改操作码允许你更改从光标到对象定义处。例如:键入 ce 以更改光标到词尾,键入c$会更改光标到行尾。 689 | 690 | 4. The format for change is: 691 | 692 | c [number] motion
693 | 更改的格式: 694 | c [number] motion 695 | 696 | Now go on to the next lesson.
697 | 现在进入 下一课吧。 698 | 699 | 700 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 701 | ## Lesson 4.1: CURSOR LOCATION AND FILE STATUS 702 | ## 4.1节:光标定位和文件状态 703 | 704 | **Type CTRL-G to show your location in the file and the file status.** 705 | **Type G to move to a line in the file.**
706 | **键入 CTRL-G 以显示你在文件中的位置和状态.** 707 | **键入G 以移动到文件行尾。** 708 | 709 | NOTE: Read this entire lesson before executing any of the steps!!
710 | 注:执行任何一步前请读完本课。 711 | 712 | 1. Hold down the Ctrl key and press g . We call this CTRL-G. 713 | A message will appear at the bottom of the page with the filename and the 714 | position in the file. Remember the line number for Step 3.
715 | 按住CTRL键,并键入 g. 我们称之为CTRL-G。 716 | 在页面的底部会呈现一个信息,指出文件名和当前文件位置。
记住行号 717 | 以在第三步使用。 718 | 719 | NOTE: You may see the cursor position in the lower right corner of the screen 720 | This happens when the 'ruler' option is set (see :help 'ruler' )
721 | 注: 你可能见到 处于屏幕右下角的光标 722 | 这发生在设置了‘ruler'选项时(见 :help 'ruler') 723 | 724 | 2. Press G to move you to the bottom of the file. 725 | Type gg to move you to the start of the file.
726 | 按 G 以移动到文件底。 727 | 键入 gg 以移动到文件首。 728 | 729 | 3. Type the number of the line you were on and then G . This will 730 | return you to the line you were on when you first pressed CTRL-G.
731 | 键入你之前所在 的行号,然后键入G。 732 | 这样你会返回到你之前,即你按CTRL-G时的那一行。 733 | 734 | 4. If you feel confident to do this, execute steps 1 through 3.
735 | 如果你有信心去做它,请执行1到3步。 736 | 737 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 738 | ## Lesson 4.2: THE SEARCH COMMAND 739 | ## 4.2节:搜索命令 740 | 741 | 742 | **Type / followed by a phrase to search for the phrase.**
743 | **按 / 并接一个要搜索的短语** 744 | 745 | 1. In Normal mode type the / character. Notice that it and the cursor 746 | appear at the bottom of the screen as with the : command.
747 | 在正常模式,键入 / 字母。注意,像:命令一样,光标会出现在屏幕底 748 | 749 | 2. Now type 'errroor' . This is the word you want to search for.
750 | 现在,键入 'errroor'.这是你想要搜索的单词。 751 | 3. To search for the same phrase again, simply type n . 752 | To search for the same phrase in the opposite direction, type N .
753 | 想再次搜索相同的短语,简单的键入 n. 754 | 想再次搜索相同的短语并以相反的方向,键入 N. 755 | 756 | 4. To search for a phrase in the backward direction, use ? instead of / .
757 | 要反向搜索一个短语,使用?替换/. 758 | 759 | 5. To go back to where you came from press CTRL-O (Keep Ctrl down while 760 | pressing the letter o). Repeat to go back further. CTRL-I goes forward.
761 | 要返回之前的位置,键入 CTRL-O(按住 CTRL时,按下字母o).重复几次回到 762 | 更早的那刻。CTRL-I是向前移动。 763 | 764 | ---> "errroor" is not the way to spell error; errroor is an error. 765 | NOTE: When the search reaches the end of the file it will continue at the 766 | start, unless the 'wrapscan' option has been reset.
767 | 注: 当搜索到达文件尾时,它会从文件头开始搜索,除非’wrapscan'选项被设置了。 768 | 769 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 770 | ## Lesson 4.3: MATCHING PARENTHESES SEARCH 771 | ## 4.3节:括号匹配搜索 772 | 773 | 774 | **Type \% to find a matching ),], or } .**
775 | **键入 \% 以找到所匹配的\),\],or \}.** 776 | 777 | 1. Place the cursor on any (, [, or { in the line below marked --->.
778 | 在以--->标记的行中,将光标定位到任一的(,[,{. 779 | 780 | 2. Now type the % character.
781 | 现在按下 %字符。 782 | 783 | 3. The cursor will move to the matching parenthesis or bracket.
784 | 将光标移动到匹配的括号上。 785 | 786 | 4. Type % to move the cursor to the other matching bracket.
787 | 按 % 以移动光标到其它的匹配括号。 788 | 789 | 5. Move the cursor to another (,),[,],{ or } and see what % does.
790 | 移动光标到 另外的(,),[,],{ or },看看 % 是怎么做的。 791 | 792 | ---> This ( is a test line with ('s, ['s ] and {'s } in it. )) 793 | 794 | 795 | NOTE: This is very useful in debugging a program with unmatched parentheses!
796 | 注:在高度程序的非匹配括号是这个是相当有用的。 797 | 798 | 799 | 800 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 801 | ## Lesson 4.4: THE SUBSTITUTE COMMAND 802 | ## 4.4:替换命令 803 | 804 | 805 | **Type :s/old/new/g to substitute 'new' for 'old'.**
806 | **键入 :s/old/new/g 以用’new'替换‘old’。** 807 | 808 | 1. Move the cursor to the line below marked --->.
809 | 移动光标到以下以--->标记的行。 810 | 811 | 2. Type :s/thee/the . Note that this command only changes the 812 | first occurrence of "thee" in the line.
813 | 键入 :s/thee/the .注意此命令仅会更改本行的第一例"thee". 814 | 815 | 3. Now type :s/thee/the/g . Adding the g flag means to substitute 816 | globally in the line, change all occurrences of "thee" in the line.
817 | 现在 键入 :s/three/the/g. 加入的 g 标志 意味着 会替换本行所有的“thee". 818 | 819 | ---> thee best time to see thee flowers is in thee spring. 820 | 821 | 822 | 4. To change every occurrence of a character string between two lines,
823 | - type :#,#s/old/new/g where #,# are the line numbers of the range of lines where the substitution is to be done.
824 | - Type :%s/old/new/g to change every occurrence in the whole file.
825 | - Type :%s/old/new/gc to find every occurrence in the whole file, 826 | with a prompt whether to substitute or not.
827 | 828 | 要更改两行间的所有的匹配字符串:
829 | - type :#,#s/old/new/g 其中,#,#是要更改的行号的范围
830 | - type :%s/old/new/g 更改全文件中的所有事件。
831 | - Type :%s/old/new/gc 更改全文件中的所有事件,并给出替换与否的提示。
832 | 833 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 834 | ## Lesson 4 SUMMARY 835 | ## 第4课总结 836 | 837 | 1. CTRL-G displays your location in the file and the file status.
838 | CTRL-G 显示 当前文件位置和状态。
839 | - G moves to the end of the file.
840 | G 移动到文件尾。
841 | - number G moves to that line number.
842 | 数字 G 移动到某行。
843 | - gg moves to the first line.
844 | gg 移动到文件头。
845 | 846 | 847 | 2. Typing / followed by a phrase searches FORWARD for the phrase.
848 | 键入 / ,接上要向前搜索的短语。
849 | - Typing ? followed by a phrase searches BACKWARD for the phrase.
850 | 键入 ? 接上要向后搜索的短语
851 | - After a search type n to find the next occurrence in the same direction
852 | - or N to search in the opposite direction.
853 | 搜索后,按n 以相同的方向搜索下一事件,按N以相反的方向搜索。
854 | - CTRL-O takes you back to older positions, CTRL-I to newer positions.
855 | CTRL-O 使你返回到以前的位置,CTRL-I 回到以后的位置 。
856 | 857 | 858 | 3. Typing % while the cursor is on a (,),[,],{, or } goes to its match.
859 | 键入 % 时括号上的光标会匹配自己的括号。
860 | 861 | 4. To substitute new for the first old in a line type :s/old/new
862 | 在一行中以new替换old. :s/old/new
863 | - To substitute new for all 'old's on a line type :s/old/new/g
864 | 在一行中以new替换所有的old :s/old/new/g
865 | - To substitute phrases between two line #'s type :#,#s/old/new/g
866 | 在#到#两行间,以new 替换所有的old :#,#s/old/new/g
867 | - To substitute all occurrences in the file type :%s/old/new/g
868 | 替换文件中的所有事件 :%s/old/new/g
869 | - To ask for confirmation each time add 'c' :%s/old/new/gc
870 | 每次替换前确认,增加‘c’' :%s/old/new/gc
871 | 872 | 873 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 874 | ## Lesson 5.1: HOW TO EXECUTE AN EXTERNAL COMMAND 875 | ## 5.1节:怎样执行外部命令 876 | 877 | 878 | **Type :! followed by an external command to execute that command.**
879 | **按 :! 并加上要执行的外部命令。** 880 | 1. Type the familiar command : to set the cursor at the bottom of the 881 | screen. This allows you to enter a command-line command.
882 | 键入类似的命令: 使光标处于屏幕底。这允许你键入一个命令行。 883 | 884 | 2. Now type the ! (exclamation point) character. This allows you to 885 | execute any external shell command.
886 | 现在键入 ! 字符。这允许你执行一个任何外部的shell命令 887 | 888 | 3. As an example type ls following the ! and then hit . This 889 | will show you a listing of your directory, just as if you were at the 890 | shell prompt. Or use :!dir if ls doesn't work
891 | 作为一个例子,键入 ls 接一个!,然后敲击.这会显示一个你的目录, 892 | 就像你在一个shell提示符一样。或者 使用 :!dir (如果 ls不起作用的话)。 893 | 894 | NOTE: It is possible to execute any external command this way, also with arguments.
895 | 注: 通过这种方式执行任何的外部命令是可能的,同样可以跟参数。 896 | 897 | NOTE: All : commands must be finished by hitting 898 | From here on we will not always mention it.
899 | 注: 所有的 : 命令必须以敲击结束。 900 | 从这里开始,我们不会问题提及这些问题。 901 | 902 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 903 | ## Lesson 5.2: MORE ON WRITING FILES 904 | ## 5.2节:其它的写文件命令 905 | 906 | **To save the changes made to the text, type :w FILENAME.**
907 | **要保存对文本作的改动,键入 :w FILENAME.** 908 | 909 | 1. Type :!dir or :!ls to get a listing of your directory. 910 | You already know you must hit after this.
911 | 键入 :!dir or :!ls 以得到你的目录的清单。 912 | 你已经 知道了你必须在这句后 敲击. 913 | 2. Choose a filename that does not exist yet, such as TEST.
914 | 选择一个不存在的文件名,如TEST。 915 | 916 | 3. Now type: :w TEST (where TEST is the filename you chose.)
917 | 现在 键入 : :w TEST (其中的TEST是你选择的文件名)。 918 | 919 | 4. This saves the whole file (the Vim Tutor) under the name TEST. 920 | To verify this, type :!dir or :!ls again to see your directory
921 | 这会以TEST的名字 保存全部文件(即这个 VIM教程)。 922 | 要确认之,请键入 :!dir or :!ls 以查看你的目录。 923 | 924 | NOTE: If you were to exit Vim and start it again with vim TEST , the file 925 | would be an exact copy of the tutor when you saved it.
926 | 注:如果你之前退出了VIM并以vim TEST再次启动了它,这个文件就会是你保存时的教 927 | 程的副本。 928 | 929 | 5. Now remove the file by typing (MS-DOS): :!del TEST 930 | or (Unix): :!rm TEST
931 | 现在键入以下命令删除这个文件: 932 | (MS-DOS): :!del TEST 933 | or (Unix): :!rm TEST 934 | 935 | 936 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 937 | ## Lesson 5.3: SELECTING TEXT TO WRITE 938 | ## 5.3节:选择要写的文本 939 | 940 | **To save part of the file, type v motion :w FILENAME**
941 | **要保存部分文件,键入 v 对象 :w FILENAME** 942 | 943 | 1. Move the cursor to this line.
944 | 移动光标到此行。 945 | 946 | 2. Press v and move the cursor to the fifth item below. Notice that the 947 | text is highlighted.
948 | 按 v 并移动 光标到 以下的第5项。注意这些文本会珵高亮。 949 | 950 | 3. Press the : character. At the bottom of the screen :'<,'> will appear.
951 | 按 :字符。在屏幕底会显示 :'<,'> will appear. 952 | 953 | 4. Type w TEST , where TEST is a filename that does not exist yet. Verify 954 | that you see :'<,'\>w TEST before you press Enter.
955 | 按 w TEST ,其中 TEST 是一个不存在 的文件。 956 | 确认你按前你看到了:'<,'\>w TEST. 957 | 958 | 5. Vim will write the selected lines to the file TEST. Use :!dir or !ls 959 | to see it. Do not remove it yet! We will use it in the next lesson.
960 | vim 会把选定的行进文件TEST中,使用 :!dir or !ls 作检查。先别删除它! 961 | 我们会下节使用它。 962 | 963 | NOTE: Pressing v starts Visual selection. You can move the cursor around 964 | to make the selection bigger or smaller.
Then you can use an operator 965 | to do something with the text. For example, d deletes the text.
966 | 注: 按下v 开始选择选择。你可以将光标移动到其它地方以使选择的区变大或者 变小。
967 | 然后你可使用操作码对文本做一些事。比如,d 删除文件。 968 | 969 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 970 | ## Lesson 5.4: RETRIEVING AND MERGING FILES 971 | ## 5.4节:恢复和合并文件 972 | 973 | 974 | **To insert the contents of a file, type :r FILENAME**
975 | **要插入一个文件的内容键入:r FILENAME** 976 | 977 | 1. Place the cursor just above this line. 978 | 979 | NOTE: After executing Step 2 you will see text from Lesson 5.3. Then movek DOWN to see this lesson again.
980 | 只需将光标放到这一行。 981 | 注: 执行第二步后你会看到5.3节的内容。然后下移并再次查看这节。 982 | 983 | 2. Now retrieve your TEST file using the command :r TEST where TEST is 984 | the name of the file you used. 985 | The file you retrieve is placed below the cursor line.
986 | 现在 恢复 你的TEST文件,使用命令 :r TEST 其中,TEST 是你使用的文件。 987 | 你要恢复的文件将被放置在光标行下面。 988 | 989 | 3. To verify that a file was retrieved, cursor back and notice that there 990 | are now two copies of Lesson 5.3, the original and the file version.
991 | 要确认文件被恢复了,用光标返回,注意这里有两5.3节的副本,原本的文件版。 992 | 993 | NOTE: You can also read the output of an external command. For example, 994 | :r !ls reads the output of the ls command and puts it below the 995 | cursor.
996 | 注: 你可能会阅读外部命令的输出。如 :r !ls 读入ls命令的输出并将其放置到 997 | 光标下。 998 | 999 | 1000 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1001 | ## Lesson 5 SUMMARY 1002 | ## 第5课总结 1003 | 1004 | 1005 | 1. :!command executes an external command. 1006 | 1007 | Some useful examples are: 1008 | (MS-DOS) (Unix) 1009 | :!dir :!ls - shows a directory listing. 1010 | :!del FILENAME :!rm FILENAME - removes file FILENAME.
1011 | 1012 | :!command 执行外部命令 1013 | 1014 | 一些有用的例子: 1015 | (MS-DOS) (Unix) 1016 | :!dir :!ls - 显示目录清单 1017 | :!del FILENAME :!rm FILENAME - 移除 FILENAME文件。 1018 | 1019 | 2. :w FILENAME writes the current Vim file to disk with name FILENAME.
1020 | :w FILENAME 将当前的vim 文件以FILENAME 文件名写进磁盘 。 1021 | 1022 | 3. v motion :w FILENAME saves the Visually selected lines in file 1023 | FILENAME.
1024 | v 对象 :w FILENAME 保存选定选择行到FILENAME 文件。 1025 | 1026 | 4. :r FILENAME retrieves disk file FILENAME and puts it below the 1027 | cursor position.
1028 | :r FILENAME 恢复磁盘文件FILENAME到光标下。 1029 | 1030 | 5. :r !dir reads the output of the dir command and puts it below the 1031 | cursor position.
1032 | :r !dir 读取dir命令的输出并粘贴到光标下。 1033 | 1034 | 1035 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1036 | ## Lesson 6.1: THE OPEN COMMAND 1037 | ## 6.1节:OPEN 命令 1038 | 1039 | 1040 | **Type o to open a line below the cursor and place you in Insert mode.**
1041 | **键入 o 以在光标打开一行,并置于插入模式。** 1042 | 1043 | 1. Move the cursor to the line below marked --->.
1044 | 移动光标到以--->标记的行。 1045 | 1046 | 2. Type the lowercase letter o to open up a line BELOW the cursor and place 1047 | you in Insert mode.
1048 | 键入 小写字母 o 以在光标下插入一行,并置于插入模式。 1049 | 1050 | 3. Now type some text and press to exit Insert mode.
1051 | 现在 键入 一些文本,并按以退出插入模式。 1052 | 1053 | ---> After typing o the cursor is placed on the open line in Insert mode. 1054 | 1055 | 4. To open up a line ABOVE the cursor, simply type a capital O , rather 1056 | than a lowercase o. Try this on the line below.
1057 | 要在光标前插入一行,只需键入 大写字母 O,而非小写字母 o,在下一行试试。 1058 | 1059 | ---> Open up a line above this by typing O while the cursor is on this line. 1060 | 1061 | 1062 | 1063 | 1064 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1065 | ## Lesson 6.2: THE APPEND COMMAND 1066 | ## 6.2: 追加命令 1067 | 1068 | **Type a to insert text AFTER the cursor.**
1069 | **键入 a 以在光标后插入文本.** 1070 | 1071 | 1. Move the cursor to the start of the line below marked --->.
1072 | 移动 下面以--->标记的行首。 1073 | 1074 | 2. Press e until the cursor is on the end of li .
1075 | 按 e 直到 光标在li 尾。 1076 | 1077 | 3. Type an a (lowercase) to append text AFTER the cursor.
1078 | 铵 一个 a(小写) 以追加文本到光标后。 1079 | 1080 | 4. Complete the word like the line below it. Press to exit Insert 1081 | mode.
1082 | 按照下一行完成这个单词。按退出插入模式。 1083 | 1084 | 5. Use e to move to the next incomplete word and repeat steps 3 and 4.
1085 | 使用 e 移动到未完成的单词,并重复步骤3和4. 1086 | 1087 | ---> This li will allow you to pract appendi text to a line. 1088 | ---> This line will allow you to practice appending text to a line. 1089 | 1090 | NOTE: a, i and A all go to the same Insert mode, the only difference is where 1091 | the characters are inserted.
1092 | 注: a,i 和A 都会进入插入模式,仅有的不同是字符在哪里插入。 1093 | 1094 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1095 | ## Lesson 6.3: ANOTHER WAY TO REPLACE 1096 | ## 6.3节: 以别一种方式替换 1097 | 1098 | 1099 | **Type a capital R to replace more than one character.**
1100 | **键入 大写 R 以替换 更多的字符而非一个。** 1101 | 1102 | 1. Move the cursor to the first line below marked --->. Move the cursor to 1103 | the beginning of the first xxx .
1104 | 移动光标到以---》标记的第一行。移动光标到第一个XXX。 1105 | 1106 | 2. Now press R and type the number below it in the second line, so that it 1107 | replaces the xxx .
1108 | 现在 按下 R 并键入 在第二行显示的数字,以其替换xxx. 1109 | 1110 | 3. Press to leave Replace mode. Notice that the rest of the line 1111 | remains unmodified.
1112 | 按下 以 离开替换模式。注意 剩余的行仍没有改变。 1113 | 1114 | 4. Repeat the steps to replace the remaining xxx.
1115 | 重复以上步骤以替换剩余的XXX。 1116 | 1117 | ---> Adding 123 to xxx gives you xxx. 1118 | ---> Adding 123 to 456 gives you 579. 1119 | 1120 | NOTE: Replace mode is like Insert mode, but every typed character deletes an 1121 | existing character.
1122 | 注: 替换模式下类似于插入模式,但是键入字符会删除已经存在的字符。 1123 | 1124 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1125 | ## Lesson 6.4: COPY AND PASTE TEXT 1126 | ## 6.4: 复制粘贴文本 1127 | 1128 | 1129 | **Use the y operator to copy text and p to paste it**
1130 | **用y 操作码来复制文本,以 p 粘贴此文本.** 1131 | 1132 | 1. Go to the line marked with ---> below and place the cursor after "a)"
1133 | 移动到以--->标记的行并定位到“a)”后。 1134 | 1135 | 2. Start Visual mode with v and move the cursor to just before "first".
1136 | 以v 开启选择模式,移动光标到“first”前。 1137 | 1138 | 3. Type y to yank (copy) the highlighted text.
1139 | 按 y 以复制高亮的文本。 1140 | 1141 | 4. Move the cursor to the end of the next line: j$
1142 | 移动 光标到下一行的:j$ 1143 | 1144 | 5. Type p to put (paste) the text. Then type: a second \ .
1145 | 按p 以粘贴文本,然后键入:a second \. 1146 | 1147 | 6. Use Visual mode to select " item.", yank it with y , move to the end of 1148 | the next line with j$ and put the text there with p .
1149 | 使用选择模式以选择” item。“,以y复制之,以j$移动到下行并以p粘贴到那里。 1150 | 1151 | ---> a) this is the first item. 1152 | b) 1153 | 1154 | NOTE: you can also use y as an operator; yw yanks one word.
1155 | 注: 你可能会使用y 作操作码;yw 复制一个单词。 1156 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1157 | ## Lesson 6.5: SET OPTION 1158 | ## 6.5节:设置选项 1159 | 1160 | 1161 | **Set an option so a search or substitute ignores case**
1162 | **设置搜索和替换时忽略大小写的选项** 1163 | 1164 | 1. Search for 'ignore' by entering: /ignore \ 1165 | Repeat several times by pressing n .
1166 | 搜索’ignore‘ ,键入 : /ignore \ 1167 | 重复按n几次。 1168 | 1169 | 2. Set the 'ic' (Ignore case) option by entering: :set ic
1170 | 设置 ’ic‘(忽略大小写)选项,键入: :set ic 1171 | 1172 | 3. Now search for 'ignore' again by pressing n 1173 | Notice that Ignore and IGNORE are now also found.
1174 | 现在 以n再次搜索'ignore'. 1175 | 注意,Ignore and IGNORE都可以被搜到。 1176 | 1177 | 4. Set the 'hlsearch' and 'incsearch' options: :set hls is
1178 | 设置选项'hlsearch' and 'incsearch': set hls is 1179 | 1180 | 5. Now type the search command again and see what happens: /ignore \
1181 | 同在键入搜索命令,看看发生 了什么: /ignore \ 1182 | 1183 | 6. To disable ignoring case enter: :set noic
1184 | 要禁止忽略大小写,键入: :set noic 1185 | 1186 | NOTE: To remove the highlighting of matches enter: :nohlsearch
1187 | 注意: 要删除高亮匹配,键入: :nohlsearch 1188 | NOTE: If you want to ignore case for just one search command, use \c 1189 | in the phrase: /ignore\c \
1190 | 注: 如果 你只是想在某次搜索命令时忽略大小写,在短语后加上\c: /ignore\c \ 1191 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1192 | ## Lesson 6 SUMMARY 1193 | ## 第6课总结 1194 | 1195 | 1. Type o to open a line BELOW the cursor and start Insert mode. 1196 | Type O to open a line ABOVE the cursor.
1197 | 按o 以插入一行,在光标后,并进入插入模式。 1198 | 按O 以在光标前插入一行。 1199 | 1200 | 2. Type a to insert text AFTER the cursor. 1201 | Type A to insert text after the end of the line.
1202 | 按a 以在光标后插入文本。 1203 | 按A在行尾插入文本。 1204 | 1205 | 3. The e command moves to the end of a word.
1206 | e命令使光标移动到单词尾。 1207 | 1208 | 4. The y operator yanks (copies) text, p puts (pastes) it.
1209 | y操作码 复制文本,p 粘贴此文本。 1210 | 1211 | 5. Typing a capital R enters Replace mode until \ is pressed.
1212 | 调入大写字母R,进入替换模式,直到\按下。 1213 | 1214 | 6. Typing ":set xxx" sets the option "xxx". Some options are:
1215 | 'ic' 'ignorecase' ignore upper/lower case when searching
1216 | 'is' 'incsearch' show partial matches for a search phrase
1217 | 'hls' 'hlsearch' highlight all matching phrases
1218 | You can either use the long or the short option name.
1219 | 1220 | 键入":set xxx" 以设置选项 "xxx". 一些选项:
1221 | 'ic' 'ignorecase' 搜索时忽略大小写
1222 | 'is' 'incsearch' 部分显示匹配的搜索短语。
1223 | 'hls' 'hlsearch' 高亮所有匹配的短语
1224 | 你可选用长的或者短的选项名。
1225 | 1226 | 7. Prepend "no" to switch an option off: :set noic
1227 | 前置”no"以关闭选项: :set noic
1228 | 1229 | 1230 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1231 | ## Lesson 7.1: GETTING HELP 1232 | ## 7.1节:使用帮助 1233 | 1234 | 1235 | **Use the on-line help system**
1236 | **使用在线帮助系统** 1237 | 1238 | Vim has a comprehensive on-line help system. To get started, try one of 1239 | these three: 1240 | - press the \ key (if you have one) 1241 | - press the \ key (if you have one) 1242 | - type :help \
1243 | vim 有一个广泛的在线帮助系统。要启用之,可试试这三种之一: 1244 | - 按 \ (如果你有) 1245 | - 按 \ (如果你有) 1246 | - 按 :help \ 1247 | 1248 | Read the text in the help window to find out how the help works. 1249 | Type CTRL-W CTRL-W to jump from one window to another. 1250 | Type :q \ to close the help window.
1251 | 阅读help窗口以查看help是如何进行的。 1252 | Type CTRL-W CTRL-W 从一个窗口跳转到另一个窗口。 1253 | Type :q \ 关闭帮助 窗口。 1254 | 1255 | You can find help on just about any subject, by giving an argument to the 1256 | ":help" command. Try these (don't forget pressing \): 1257 | 1258 | :help w 1259 | :help c\_CTRL-D 1260 | \:help insert-index 1261 | :help user-manual
1262 | 你可以通过为":help"给一个参数找到任何主题的帮助,试试这些(别忘了\) 1263 | :help w 1264 | :help c\_CTRL-D 1265 | :help insert-index 1266 | :help user-manual 1267 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1268 | ## Lesson 7.2: CREATE A STARTUP SCRIPT 1269 | ## 7.2节:创建启动脚本 1270 | 1271 | 1272 | **Enable Vim features**
1273 | **启用VIM特性**
1274 | Vim has many more features than Vi, but most of them are disabled by 1275 | default. To start using more features you have to create a "vimrc" file.
1276 | VIM 拥有比vi更多的特性,但是大多数是被默认禁止的。要使用更多的 1277 | 特性,你可创建“vimrc”文件。 1278 | 1279 | 1. Start editing the "vimrc" file. This depends on your system: 1280 | :e ~/.vimrc for Unix 1281 | :e $VIM/\_vimrc for MS-Windows
1282 | 开始编辑“vimrc”文件,这依赖于你的系统。 1283 | :e ~/.vimrc for Unix 1284 | :e $VIM/\_vimrc for MS-Windows 1285 | 2. Now read the example "vimrc" file contents: 1286 | :r $VIMRUNTIME/vimrc\_example.vim
1287 | 现在阅读下“vimrc”文件的例子: 1288 | :r $VIMRUNTIME/vimrc\_example.vim 1289 | 1290 | 3. Write the file with:保存文件 1291 | :w 1292 | 1293 | The next time you start Vim it will use syntax highlighting. 1294 | You can add all your preferred settings to this "vimrc" file. 1295 | For more information type :help vimrc-intro
1296 | 下次,你启动VIM后,它会使语法高亮,你可以在“vimrc”中添加所有你喜欢的 1297 | 设置。 1298 | 更多信息请键入 :help vimrc-intro 1299 | 1300 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1301 | ## Lesson 7.3: COMPLETION 1302 | ## 7.3节:补齐 1303 | 1304 | **Command line completion with CTRL-D and \**
1305 | **使用CTRL-D和\使命令行补齐** 1306 | 1307 | 1. Make sure Vim is not in compatible mode: :set nocp
1308 | 确保VIM 处于非兼容模式: :set nocp 1309 | 1310 | 2. Look what files exist in the directory: :!ls or :!dir
1311 | 看看目录下有什么文件存在: :!ls or :!dir 1312 | 1313 | 3. Type the start of a command: :e
1314 | 键入命令的开始部分: :e 1315 | 1316 | 4. Press CTRL-D and Vim will show a list of commands that start with "e".
1317 | 按 CTRL-D ,VIM会显示以“e”开头的清单。 1318 | 1319 | 5. Press \ and Vim will complete the command name to ":edit".
1320 | 按下\,VIM会以“:edit"补齐命令名。 1321 | 1322 | 6. Now add a space and the start of an existing file name: :edit FIL
1323 | 现在 添加一个空格和己存的文件名头部: :edit FIL 1324 | 1325 | 7. Press \. Vim will complete the name (if it is unique)
1326 | 按\,vim会完成余下的文件名(如果它是独有的话)。 1327 | 1328 | NOTE: Completion works for many commands. Just try pressing CTRL-D and 1329 | \. It is especially useful for :help .
1330 | 注:补齐针对大多数命令有效,只需按CTRL-D和\.特别是对 :help 非常有用 。 1331 | 1332 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1333 | ## Lesson 7 SUMMARY 1334 | ## 第七课总结 1335 | 1336 | 1. Type :help or press \ or \ to open a help window.
1337 | 键入 :help 或 \ 或\以打开帮助窗口 1338 | 1339 | 2. Type :help cmd to find help on cmd .
1340 | 键入 :help cmd 以找出关于cmd的帮助 。 1341 | 1342 | 3. Type CTRL-W CTRL-W to jump to another window
1343 | 键入 CTRL-W 以跳转到另一窗口。 1344 | 1345 | 4. Type :q to close the help window
1346 | 键入 :q 以关闭帮助窗口。 1347 | 1348 | 5. Create a vimrc startup script to keep your preferred settings.
1349 | 创建 vimrc 启动脚本以保存你喜欢的设置。 1350 | 1351 | 6. When typing a : command, press CTRL-D to see possible completions. 1352 | Press \ to use one completion.
1353 | 当键入 :command 时,按下CTRL-D 以查看可能的补齐。 1354 | 按\使用其中一个补齐。 1355 | 1356 | 1357 | 1358 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1359 | 1360 | This concludes the Vim Tutor. It was intended to give a brief overview of 1361 | the Vim editor, just enough to allow you to use the editor fairly easily. 1362 | It is far from complete as Vim has many many more commands. Read the user 1363 | manual next: ":help user-manual".
1364 | 本文总结了vim教程。它原本给出了VIM编辑器的简短的概要,只能足以让你很容易地 1365 | 使用编辑器。这远没有完成,因为VIM在如此众多的命令。请阅读下面的用户手册: 1366 | :help user-manual 1367 | 1368 | For further reading and studying, this book is recommended: 1369 | Vim - Vi Improved - by Steve Oualline 1370 | Publisher: New Riders 1371 | The first book completely dedicated to Vim. Especially useful for beginners. 1372 | There are many examples and pictures. 1373 | See http://iccf-holland.org/click5.html
1374 | 1375 | 要进一步的阅读和学习,我们推荐这本书: 1376 | Vim - Vi Improved -作者Steve Oualline 1377 | 出版社:New Riders 1378 | 第一本书专门针对 Vim. 特别适合 新手. 1379 | 其中有许多实例和图示。 1380 | See http://iccf-holland.org/click5.html 1381 | 1382 | 1383 | This book is older and more about Vi than Vim, but also recommended: 1384 | Learning the Vi Editor - by Linda Lamb 1385 | Publisher: O'Reilly & Associates Inc. 1386 | It is a good book to get to know almost anything you want to do with Vi. 1387 | The sixth edition also includes information on Vim.
1388 | 1389 | 这本书比较老并且主要内容是VI而非vim,但是仍值得推荐: 1390 | Learning the Vi Editor - by Linda Lamb 1391 | 出版社: O'Reilly & Associates Inc. 1392 | 它是一本能告诉你你想利用VI做的几乎所有事情的好书。 1393 | 此书的第三版也包含了有关VIM的内容。 1394 | 1395 | 1396 | This tutorial was written by Michael C. Pierce and Robert K. Ware, 1397 | Colorado School of Mines using ideas supplied by Charles Smith, 1398 | Colorado State University. E-mail: bware@mines.colorado.edu. 1399 | Modified for Vim by Bram Moolenaar.
1400 | 1401 | 本教程由科罗拉多矿业学院的Michael C. Pierce 和 Robert K. Ware编写,同时Charles Smith 提供了很多创意。 1402 | E-mail: bware@mines.colorado.edu. 1403 | Bram Moolenaar 为VIM对本教程作了修订。 1404 | 1405 | \~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1406 | ## 下面是一些补充: 1407 | CTRL+F:往下翻页
1408 | CTRL+B:往上翻页
1409 | 1410 | CTRL+E: 往下滚动
1411 | CTRL+Y: 往上滚动
1412 | 1413 | ### 行的拼接: 1414 | 在选择模式选中要拼接的行:ggvG
1415 | 输入: :'\<,'\>j\
1416 | 注:普通的j用于拼接单行。
1417 | 1418 | ### 列操作: 1419 | -选中全文的第一列
1420 | -按gg跳至开头
1421 | -按CTRL——V进入列选择状态:visula block
1422 | -按G到末尾
1423 | 1424 | ### 将每行的第一列变为大写 1425 | -按U将选中内容变大写
1426 | -按u将选中内容变小写
1427 | -按~将大小翻转。
1428 | 1429 | ### 列操作:在第行前加一个星号和空格: 1430 | -选中第一列
1431 | -按I进入插入状态
1432 | -输入: 1433 | ``` 1434 | * 1435 | ``` 1436 | -选中前两列后按x,可时行列删除
1437 | 1438 | ### 宏的录制:将所有偶数行后加入OK! 1439 | -按gg进入第一行
1440 | -按qm进入宏录制
1441 | -按j$进入第二行尾
1442 | -按aok!以输入ok!
1443 | -按\返回
1444 | -按j到下一行
1445 | -按q结束宏录制
1446 | 1447 | ### 宏的播放:(接上面的步骤) 1448 | 单次播放:
1449 | -按下@m,执行m寄存器中的宏
1450 | -可以发现第4行中的尾已经加入了ok!
1451 | 多次播放:
1452 | -按下100@m,这里重复播放100次宏。
1453 | 点号(重复上一次命令):
1454 | 1455 | ### 将第行尾加一个感叹号 1456 | -按ggA!以在第一行添加感叹号
1457 | -按\j以到下一行。
1458 | -按.表示重复前一个操作,即在执行A!\以在行尾添加一个感叹号。
1459 | -反复按j.j.j.j.j.
1460 | :%s/$/!/g
1461 | 1462 | 1463 | 1464 | \========================.vimrc for beginners================== 1465 | ## 基本设置 1466 | set nocp 设置不兼容模式
1467 | set ru 打开状态栏标尺
1468 | set hls 搜索时高亮显示找到的文本
1469 | set is 递进搜索
1470 | syntax on 打开关键字上色
1471 | set backspace=indent,eol,start
1472 | set whichrap=b,s,\<,>,[,]
1473 | \ h,l,~
1474 | set sw=4 缩进尺寸4个空格
1475 | set ts=4 Tab宽度为4个字符
1476 | set et 将所有的TAB替换为空格
1477 | 1478 | C/C++编码设置
1479 | set cin 自动缩进
1480 | set ai 还是自动缩进
1481 | set cino=:0g0t0(sus
1482 | set sm 显示括号匹配
1483 | 1484 | 在console下粘贴版式的问题
1485 | :set paste
1486 | :set nopaste
1487 | = 命令重调格式
1488 | 1489 | 断行设置
1490 | set lbr 不在单词中间断行
1491 | 1492 | 图形界面与字符界面分别设置
1493 | if (has("gui\_running"))
1494 | 1495 | 图形界面设置
1496 | set nowrap 不拆行
1497 | set guioptions+=b 水平流动条
1498 | colo torte 配色方案
1499 | else 1500 | 1501 | 字符界面设置
1502 | set wrap 拆行
1503 | colo ron 配色方案
1504 | endif
1505 | 1506 | 1507 | 1508 | [vim]: https://github.com/vim/vim 1509 | [vimorg]: http://www.vim.org/ 1510 | [SpaceVim]: https://github.com/SpaceVim/SpaceVim.git 1511 | [hackspvim]: https://github.com/Gabirel/Hack-SpaceVim 1512 | [galore]: https://github.com/mhinz/vim-galore 1513 | [note]: README_NOTE.md 1514 | -------------------------------------------------------------------------------- /README_NOTE.md: -------------------------------------------------------------------------------- 1 | # vimtutor 读书笔记 2 | 3 | ## 第一课 文本编辑 4 | 5 | ### 打开 保存 退出 6 | 7 | **在命令模式下** 8 | 9 | | 命令 | 功能 | 10 | |---|---| 11 | | :e test.md | 打开 test.md文件, 如果不存在则创建。 | 12 | | :w | 保存 | 13 | | :w! | 强制保存 | 14 | | :q | 退出 | 15 | | :wq | 保存并退出 | 16 | | :x | 同:wq | 17 | | :q! | 强制退出 不保存并退出| | 18 | 19 | ### 移动光标 20 | ※※ 要移動光標,請依照說明分別按下 h、j、k、l 鍵。 ※※ 21 | 22 | ^ 23 | k h 的鍵位于左邊,每次按下就會向左移動。 24 | < h l > l 的鍵位于右邊,每次按下就會向右移動。 25 | j j 鍵看起來很象一支尖端方向朝下的箭頭。 26 | v 27 | 28 | 29 | ### 删除和追加 30 | 31 | | 命令 | 功能 | 32 | |---|---| 33 | | x | 删除光标处的一个字符 | 34 | | a | 追加文本 | 35 | | i | 插入文本 | 36 | 37 | ## 第二课 删除命令 38 | 39 | ### 关于对象的小清单 40 | 41 | | 命令 | 功能 | 42 | |---|---| 43 | | w | 到下一个单词头,除开所在的第一个字符。 | 44 | | b | 到上一个单词头,包括所在单词的第一个字符。 | 45 | | e | 到下一个单词尾,包括所在单词的最后一个字符。 | 46 | | $ | 到行尾,包括了最后一个字符。 | 47 | | 0 | 到行首,包含空格。 | 48 | | ^ | 到行首,不含空格。 | 49 | | G | 到文本最后一行首 | 50 | | gg | 到文本首行。 | 51 | 52 | ### 恢复命令 53 | 54 | | 命令 | 功能 | 55 | |---|---| 56 | | u | 恢复之前的动作 | 57 | | U | 恢复对一行的所有改变 | 58 | | CTRL+R | 反恢复 | 59 | 60 | ### 删除操作 61 | 62 | | 命令 | 功能 | 63 | |---|---| 64 | | d | 删除 | 65 | | dd | 删除一行 | 66 | 67 | ### 更改命令的格式 68 | 69 | 操作码 [数字] 对象,例如: 70 | 71 | * d2w 72 | * 3e 73 | * 2dd 74 | 75 | ## 第三章 76 | 77 | | 命令 | 功能 | 78 | |---|---| 79 | | p | 以在光标处粘贴先前删除的文本 | 80 | | r | 替换 | 81 | | c | 修改,功能等于删除单词并定位到插入模式。c 和 d 一样属于操作码 | 82 | 83 | ## 第四课 84 | 85 | ### 光标定位和文件状态 86 | 87 | | 命令 | 功能 | 88 | |---| 89 | | CTRL+g | 在页面的底部会呈现一个信息,指出文件名和当前文件位置 | 90 | | [line number]G | 移动到指定行数 | 91 | 92 | 93 | ### 搜索命令 94 | 95 | | 命令 | 功能 | 96 | |---|---| 97 | | /keyword | 搜索 | 98 | | ?keyword | 反向搜索 | 99 | | n | 搜索下一条 | 100 | | N | 搜索上一条 | 101 | | CTRL+o | 搜索下一条 | 102 | | CTRL+i | 搜索上一条 | 103 | | % | 括号匹配搜索,可匹配 (,),[,],{ or } | 104 | 105 | ### 替换命令 106 | 107 | | 命令 | 功能 | 108 | |---|---| 109 | | :s/old/new | 替换本行第一个的 | 110 | | :s/old/new/g | 替换本行所有的 | 111 | | :%s/old/new/g | 更改全文件中的所有 | 112 | | :%s/old/new/gc | 更改全文件中的所有,并给出替换与否的提示 | 113 | | :#,#s/old/new/g | #,#是要更改的行号的范围 | 114 | 115 | ## 第五课 执行外部命令 116 | 117 | | 命令 | 功能 | 118 | |---|---| 119 | | :!command | :!command 执行外部 shell 命令。例如 :!ls | 120 | | :w FILENAME | 将当前的vim 文件以FILENAME 文件名写进磁盘 | 121 | | v 对象 :w FILENAME | 保存选定选择行到FILENAME 文件 | 122 | | :r FILENAME | 恢复磁盘文件FILENAME到光标下 | 123 | | :r !ls | 读取 ls 命令的输出并粘贴到光标下 | 124 | 125 | ## 第六课 126 | 127 | | 命令 | 功能 | 128 | |---|---| 129 | | o | 在光标后插入一行,并进入插入模式 | 130 | | O | 以在光标前插入一行 | 131 | | a | 在光标后插入文本 | 132 | | A | 在行尾插入文本 | 133 | | y | 复制命令 | 134 | | p | 粘贴命令 | 135 | | R | 进入替换模式,直到按下 | 136 | | :set xxx | 进入替换模式,直到按下 | 137 | | 'ic' 'ignorecase' | 搜索时忽略大小写,例如 :set ic | 138 | | 'is' 'incsearch' | 部分显示匹配的搜索短语 | 139 | | 'hls' 'hlsearch' | 高亮所有匹配的短语 | 140 | | :set noic | 前置”no"以关闭选项 | 141 | 142 | ## 第七课 143 | 144 | | 命令 | 功能 | 145 | |---|---| 146 | | :help | 以打开帮助窗口 | 147 | | :help cmd | 找出关于cmd的帮助 | 148 | | CTRL+w | 跳转到另一窗口 | 149 | | :command, press CTRL+d | 以查看可能的补齐 | 150 | -------------------------------------------------------------------------------- /Vimtutor.txt: -------------------------------------------------------------------------------- 1 | 感觉vimtutor是众多vim帮助文档中最好的入门教程,其中的每一个知识点都有相应 2 | 的习题,可以让你在短时间内掌握基本的VIM操作。 3 | 4 | 想要入门vim的童鞋最好还是一边看文档,一边用vim自己尝试每个命令。 5 | 6 | 请通过vim练习:vim vimtutor_cn.txt 7 | =============================================================================== 8 | = W e l c o m e t o t h e V I M T u t o r - Version 1.7 = 9 | 欢迎使用VIM教程 1.7版 10 | =============================================================================== 11 | 12 | Vim is a very powerful editor that has many commands, too many to 13 | explain in a tutor such as this. This tutor is designed to describe 14 | enough of the commands that you will be able to easily use Vim as 15 | an all-purpose editor. 16 | VIM是一个强大的编辑器,它拥有大量的命令,不可能在本教程中全部解释。但是,本 17 | 教程描述了足够多的命令,使你能轻松将VIM作为通用编辑器。 18 | 19 | The approximate time required to complete the tutor is 25-30 minutes, 20 | depending upon how much time is spent with experimentation. 21 | 完成本教程的时间大约是25-30分钟,主要依赖于你在实验中花去的时间。 22 | 23 | ATTENTION: 24 | The commands in the lessons will modify the text. Make a copy of this 25 | file to practise on (if you started "vimtutor" this is already a copy). 26 | 注意: 27 | 本课程中的命令会改变本文的内容,请创建一个副本来练习(如果你用命令“vimtutor" 28 | 开始,本文已经是自动生成的副本了)。 29 | 注:创建副本的命令为: 30 | vim -u NONE -c 'e $VIMRUNTIME/tutor/tutor' -c 'w! vimtutor_copy' -c 'q';ls -l 31 | 32 | It is important to remember that this tutor is set up to teach by 33 | use. That means that you need to execute the commands to learn them 34 | properly. If you only read the text, you will forget the commands! 35 | 很重要的一点是,要记住,本教程是用于指导VIM的使用。这意味着你需要执行命令 36 | 以正确地学习它们。如果你只是单纯阅读本文,你会很快忘记这些命令! 37 | 38 | Now, make sure that your Shift-Lock key is NOT depressed and press 39 | the j key enough times to move the cursor so that Lesson 1.1 40 | completely fills the screen. 41 | 现在,请确保你的shift键是启用的,多次按 j 键移动到1.1课,使之 42 | 居于屏幕中心。 43 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 44 | Lesson 1.1: MOVING THE CURSOR 45 | 1.1课:移动光标 46 | 47 | ** To move the cursor, press the h,j,k,l keys as indicated. ** 48 | **要移动光标,则按示意按下 h,j,k,l 键。** 49 | ^ 50 | k Hint: The h key is at the left and moves left. 51 | < h l > The l key is at the right and moves right. 52 | j The j key looks like a down arrow. 53 | v 54 | 示意: 左边的h键是往左移 55 | 右边的l键是往右移 56 | j键是往下移 57 | 1. Move the cursor around the screen until you are comfortable. 58 | 在屏幕中移动光标到你觉得合适的地方。 59 | 60 | 2. Hold down the down key (j) until it repeats. 61 | Now you know how to move to the next lesson. 62 |   按住j键,使之重复作用。 63 | 现在你知道了怎么移动到下一节了吧。 64 | 65 | 3. Using the down key, move to Lesson 1.2. 66 | 使用下移键,移动到1.2节。 67 | 68 | NOTE: If you are ever unsure about something you typed, press to place 69 | you in Normal mode. Then retype the command you wanted. 70 | 注意:如意你不确定你按下了什么,按回到正常模式。再按你想要输入的命令。 71 | 72 | NOTE: The cursor keys should also work. But using hjkl you will be able to 73 | move around much faster, once you get used to it. Really! 74 | 注意:光标键同样生效。但hjkl键会使你移动得更快,只要你熟悉了它。真的! 75 | 76 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 77 | Lesson 1.2: EXITING VIM 78 | 1。2节:退出VIM 79 | 80 | !! NOTE: Before executing any of the steps below, read this entire lesson!! 81 | !! 注:执行以下步骤前,请读完全节!! 82 | 83 | 1. Press the key (to make sure you are in Normal mode). 84 | 按下键(确保你处于正常模式)。 85 | 86 | 2. Type: :q! . 87 | This exits the editor, DISCARDING any changes you have made. 88 | 按: :q! . 89 | 此命令使编辑器退出并放弃你作的作用改动。(即不保存对文本的编辑) 90 | 91 | 3. When you see the shell prompt, type the command that got you into this 92 | tutor. That would be: vimtutor 93 | 当你看见shell提示时,输入以下命令并进入本教程:vimtutor 94 | 注:事实上你vimtutor是打开一个副本,你也可以打开你之前创建的副本: 95 | vim vimtutor_copy 96 | 97 | 4. If you have these steps memorized and are confident, execute steps 98 | 1 through 3 to exit and re-enter the editor. 99 | 如果你已经记住的这些步骤并有信心了,就执行步骤1-3退出,然后再进入编辑器。 100 | 101 | NOTE: :q! discards any changes you made. In a few lessons you 102 | will learn how to save the changes to a file. 103 | 注:q! 会取消你对文本所作的任何改动。在新的一节你会学到保存文件的修改。 104 | 105 | 5. Move the cursor down to Lesson 1.3. 106 | 移动光标到1.3节。 107 | 108 | 109 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 110 | Lesson 1.3: TEXT EDITING - DELETION 111 | 1.3节:文本编辑之删除 112 | 113 | 114 | ** Press x to delete the character under the cursor. ** 115 | **按下x键以删除光标所在的字符.** 116 | 117 | 1. Move the cursor to the line below marked --->. 118 | 移动光标到--->标记的行。 119 | 120 | 2. To fix the errors, move the cursor until it is on top of the 121 | character to be deleted. 122 | 为了修复错误,移动光标到要删除字符上。 123 | 124 | 3. Press the x key to delete the unwanted character. 125 | 按下x键以删除不想要的字符。 126 | 127 | 4. Repeat steps 2 through 4 until the sentence is correct. 128 | 重复步骤2到4,直到语句正确。 129 | 130 | ---> The ccow jumpedd ovverr thhe mooon. 131 | 132 | 5. Now that the line is correct, go on to Lesson 1.4. 133 | 现在语句正确了吧,请移步1.4节。 134 | 135 | NOTE: As you go through this tutor, do not try to memorize, learn by usage. 136 | 注:浏览本教程时,不要试着去记,而是学习其用法。 137 | 138 | 139 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 140 | Lesson 1.4: TEXT EDITING - INSERTION 141 | 1.4节:文本编辑之插入 142 | 143 | 144 | ** Press i to insert text. ** 145 | **按下 i键 以插入文本** 146 | 147 | 1. Move the cursor to the first line below marked --->. 148 | 移动光标到--->标记的行。 149 | 150 | 2. To make the first line the same as the second, move the cursor on top 151 | of the first character AFTER where the text is to be inserted. 152 | 为使第一行同第二行相同,移动光标到要插入文本处字符上。 153 | 154 | 3. Press i and type in the necessary additions. 155 | 按下i键,键入需要的字符。 156 | 157 | 4. As each error is fixed press to return to Normal mode. 158 | Repeat steps 2 through 4 to correct the sentence. 159 | 当错误被修复后,按下回到正常模式。重复步骤2到4以修改完整。 160 | 161 | ---> There is text misng this . 162 | ---> There is some text missing from this line. 163 | 164 | 5. When you are comfortable inserting text move to lesson 1.5. 165 | 当你正确插入完文本后,移步1.5节。 166 | 167 | 168 | 169 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 170 | Lesson 1.5: TEXT EDITING - APPENDING 171 | 1.5节:文本编辑之追加 172 | 173 | 174 | ** Press A to append text. ** 175 | **按下A键以追加文本** 176 | 177 | 1. Move the cursor to the first line below marked --->. 178 | It does not matter on what character the cursor is in that line. 179 | 移动光标到--->标记的行。 180 | 该行同下一行在字符上不匹配。 181 | 182 | 2. Press A and type in the necessary additions. 183 | 按下A键,然后键入要添加的内容。 184 | 185 | 3. As the text has been appended press to return to Normal mode. 186 | 当添加完文本后按下,返回到正常模式。 187 | 188 | 4. Move the cursor to the second line marked ---> and repeat 189 | steps 2 and 3 to correct this sentence. 190 | 移动光标到第二个--->标记的行。 191 | 192 | ---> There is some text missing from th 193 | There is some text missing from this line. 194 | ---> There is also some text miss 195 | There is also some text missing here. 196 | 197 | 5. When you are comfortable appending text move to lesson 1.6. 198 | 当你正确添加了文本后,请移步1.6节。 199 | 200 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 201 | Lesson 1.6: EDITING A FILE 202 | 1.6节:编辑一个文件 203 | 204 | ** Use :wq to save a file and exit. ** 205 | ** :wq 保存文件并退出。** 206 | 207 | !! NOTE: Before executing any of the steps below, read this entire lesson!! 208 | !! 注: 执行以下步骤之前,请读完全节!! 209 | 210 | 1. Exit this tutor as you did in lesson 1.2: :q! 211 | Or, if you have access to another terminal, do the following there. 212 | 像1.2节一样,退出本教程: :q! 213 | 或者,你也可以访问其它的终端,并执行以下几步。 214 | 215 | 2. At the shell prompt type this command: vim tutor 216 | 'vim' is the command to start the Vim editor, 'tutor' is the name of the 217 | file you wish to edit. Use a file that may be changed. 218 | 在shell提示符下,键入此命令: vim tutor 219 | 'vim' 是要启动的vim编辑器,‘tutor'是编辑的文件名。该文件将被编辑修改。 220 | 221 | 3. Insert and delete text as you learned in the previous lessons. 222 | 按照你在前几节你所学到的插入、删除文本。 223 | 224 | 4. Save the file with changes and exit Vim with: :wq 225 | 保存对文件的修改,并退出vim: :wq 226 | 227 | 5. If you have quit vimtutor in step 1 restart the vimtutor and move down to 228 | the following summary. 229 | 如果你在步骤1中退出了本教程,启动本教程并移步到以的总结。 230 | 231 | 6. After reading the above steps and understanding them: do it. 232 | 阅读完以下几步后,理解并执行它们。 233 | 234 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 235 | Lesson 1 SUMMARY 236 | 课程1 的 总结 237 | 238 | 239 | 1. The cursor is moved using either the arrow keys or the hjkl keys. 240 | h (left) j (down) k (up) l (right) 241 | 可以使用光标键或者hjkl键移动光标 242 | h (左移) j (下移) k (上移) l (右移) 243 | 244 | 2. To start Vim from the shell prompt type: vim FILENAME 245 | 从sheel提示符启动VIM,请键入:vim FILENAME 246 | 247 | 3. To exit Vim type: :q! to trash all changes. 248 | OR type: :wq to save the changes. 249 | 要退出VIM: :q! 放弃所有修改。 250 | 或者键入: :wq 保存所有的修改。 251 | 252 | 4. To delete the character at the cursor type: x 253 | 删除光标处的一个字符: x 254 | 255 | 5. To insert or append text type: 256 | i type inserted text insert before the cursor 257 | A type appended text append after the line 258 | 插入或者追加文本: 259 | i type inserted text 插入文本 260 | A type appended text 追加文本 261 | 262 | NOTE: Pressing will place you in Normal mode or will cancel 263 | an unwanted and partially completed command. 264 | 注: 按下 会回到正常模式,或者取消示完成的命令。 265 | 266 | Now continue with Lesson 2. 267 | 现在继续进行第2课。 268 | 269 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 270 | Lesson 2.1: DELETION COMMANDS 271 | 2.1节:删除命令 272 | 273 | 274 | ** Type dw to delete a word. ** 275 | **键入 dw 以删除一个单词.** 276 | 277 | 1. Press to make sure you are in Normal mode. 278 | 按下 以确保你牌正常模式。 279 | 280 | 2. Move the cursor to the line below marked --->. 281 | 移动光标到以下以--->标记的行。 282 | 283 | 3. Move the cursor to the beginning of a word that needs to be deleted. 284 | 移动光标到需要删除的单词头。 285 | 286 | 4. Type dw to make the word disappear. 287 | 键入 dw 以使该单词消失(被删除)。 288 | 289 | NOTE: The letter d will appear on the last line of the screen as you type 290 | it. Vim is waiting for you to type w . If you see another character 291 | than d you typed something wrong; press and start over. 292 | 注: 当你键入d时,字d 会在屏幕最低处显示,此时VIM在等待你键入w。 当你错误的键入时,你会看见其它的字符而非d;按下 重新开始。 293 | 294 | ---> There are a some words fun that don't belong paper in this sentence. 295 | 296 | 5. Repeat steps 3 and 4 until the sentence is correct and go to Lesson 2.2. 297 | 重新步骤3到4,直到语句正确,然后移步2.2节。 298 | 299 | 300 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 301 | Lesson 2.2: MORE DELETION COMMANDS 302 | 2.2节:其它的删除命令 303 | 304 | 305 | ** Type d$ to delete to the end of the line. ** 306 | ** 键入 d$ 以删除光标到行尾间处的字符。**` 307 | 308 | 1. Press to make sure you are in Normal mode. 309 | 按下 以确保你处于正常模式。 310 | 311 | 2. Move the cursor to the line below marked --->. 312 | 移动光标到以下以--->标记的行。 313 | 314 | 3. Move the cursor to the end of the correct line (AFTER the first . ). 315 | 移动光标到正确行的末端(在第一个.号后)。 316 | 317 | 4. Type d$ to delete to the end of the line. 318 | 键入 d$ 以删除到行尾。 319 | 320 | ---> Somebody typed the end of this line twice. end of this line twice. 321 | 322 | 323 | 5. Move on to Lesson 2.3 to understand what is happening. 324 | 移动到2.3节,并理解发生了什么。 325 | 326 | 327 | 328 | 329 | 330 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 331 | Lesson 2.3: ON OPERATORS AND MOTIONS 332 | 2.3节:关于操作码和对象 333 | (operator我理解为操作码,motions我理解为对象) 334 | 335 | 336 | Many commands that change text are made from an operator and a motion. 337 | The format for a delete command with the d delete operator is as follows: 338 | 339 | d motion 340 | 341 | Where: 342 | d - is the delete operator. 343 | motion - is what the operator will operate on (listed below). 344 | 345 | A short list of motions: 346 | w - until the start of the next word, EXCLUDING its first character. 347 | e - to the end of the current word, INCLUDING the last character. 348 | $ - to the end of the line, INCLUDING the last character. 349 | 350 | Thus typing de will delete from the cursor to the end of the word. 351 | 352 | NOTE: Pressing just the motion while in Normal mode without an operator will 353 | move the cursor as specified. 354 | 许多修改文本的命令由两部分组成:操作码和对象。 355 | 删除命令d的格式如下: 356 | 357 | d 对象 358 | 其中: 359 | d -是操作码 360 | motlion -是操作码要操作的对象(译者:更确切地说应是范围吧?)(罗列在下方) 361 | 关于对象的小清单: 362 | w -到下一个单词头,除开所在的第一个字符。 363 | e -到下一个单词尾,包括所在单词的最后一个字符。 364 | $- 到行尾,包括了最后一个字符。 365 | 0- 到行首,包含空格。 366 | ^ -到行首,不含空格。 367 | G -到文本最后一行首 368 | gg -到文本首行。 369 | 所以de会删除光标处到单词尾下的字符。 370 | 371 | 注: 不带操作码按下对象键时,仅会按对象指定的方式 移动光标。 372 | 373 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 374 | Lesson 2.4: USING A COUNT FOR A MOTION 375 | 2.4节:对对象使用计数 376 | 377 | 378 | ** Typing a number before a motion repeats it that many times. ** 379 | 380 | 1. Move the cursor to the start of the line marked ---> below. 381 | 382 | 2. Type 2w to move the cursor two words forward. 383 | 384 | 3. Type 3e to move the cursor to the end of the third word forward. 385 | 386 | 4. Type 0 (zero) to move to the start of the line. 387 | 388 | 5. Repeat steps 2 and 3 with different numbers. 389 | 390 | ---> This is just a line with words you can move around in. 391 | 392 | 6. Move on to Lesson 2.5. 393 | 394 | ** 在对象前键入重复的次数.** 395 | 396 | 1. 移动光标到以下以--->标记的行。 397 | 398 | 2. 键入 2w 以使光标向后移动两个单词。 399 | 400 | 3. 键入 3e 以使光标向后移动到第三个单词尾。 401 | 402 | 4. 键入 0 移动到行首。 403 | 404 | 5. 使用不同 的数字重复步骤2到3. 405 | 406 | ---> This is just a line with words you can move around in. 407 | 408 | 6. 移步到2.5节。 409 | 410 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 411 | Lesson 2.5: USING A COUNT TO DELETE MORE 412 | 2.5节:使用计数以删除得更多 413 | 414 | 415 | ** Typing a number with an operator repeats it that many times. ** 416 | ** 为操作码键入 一个数字,使之重复多次。** 417 | 418 | In the combination of the delete operator and a motion mentioned above you 419 | insert a count before the motion to delete more: 420 | d number motion 421 | 422 | 合并上文提到的删除操作码和对象,在对象前插入一个数字以删除更多 423 | d 数字 对象 424 | 425 | 1. Move the cursor to the first UPPER CASE word in the line marked --->. 426 | 移动光标到以下以--->标记的行的第一个大写单词处。 427 | 428 | 2. Type d2w to delete the two UPPER CASE words 429 | 键入 d2w 以删除2个大写 单词。 430 | 431 | 3. Repeat steps 1 and 2 with a different count to delete the consecutive 432 | UPPER CASE words with one command 433 | 用不同的计数重复步骤1和2,以一个命令删除多个连续的大写单词。 434 | 435 | ---> this ABC DE line FGHI JK LMN OP of words is Q RS TUV cleaned up. 436 | 437 | 438 | 439 | 440 | 441 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 442 | Lesson 2.6: OPERATING ON LINES 443 | 2.6节:行的操作 444 | 445 | 446 | ** Type dd to delete a whole line. ** 447 | ** 键入 dd 以删除一整行.** 448 | 449 | Due to the frequency of whole line deletion, the designers of Vi decided 450 | it would be easier to simply type two d's to delete a line. 451 | 由于需要频繁的删除一整行,vi的设计者决定通过简单的键入两d轻松删除一整行。 452 | 453 | 1. Move the cursor to the second line in the phrase below. 454 | 2. Type dd to delete the line. 455 | 3. Now move to the fourth line. 456 | 4. Type 2dd to delete two lines. 457 | 1. 移动移动到以以下短语的第二行。 458 | 2. 键入 dd 以删除行。 459 | 3. 现在移动到第四行。 460 | 4. 键入 2dd 以删除后两行。 461 | 462 | ---> 1) Roses are red, 463 | ---> 2) Mud is fun, 464 | ---> 3) Violets are blue, 465 | ---> 4) I have a car, 466 | ---> 5) Clocks tell time, 467 | ---> 6) Sugar is sweet 468 | ---> 7) And so are you. 469 | 470 | 471 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 472 | Lesson 2.7: THE UNDO COMMAND 473 | 2.7节:恢复命令 474 | 475 | 476 | ** Press u to undo the last commands, U to fix a whole line. ** 477 | ** 按下u 以恢复最后的命令,U 是修复一整行.** 478 | 479 | 1. Move the cursor to the line below marked ---> and place it on the 480 | first error. 481 | 2. Type x to delete the first unwanted character. 482 | 3. Now type u to undo the last command executed. 483 | 4. This time fix all the errors on the line using the x command. 484 | 5. Now type a capital U to return the line to its original state. 485 | 6. Now type u a few times to undo the U and preceding commands. 486 | 7. Now type CTRL-R (keeping CTRL key pressed while hitting R) a few times 487 | to redo the commands (undo the undo's). 488 | 1. 移动光标到以--->标记的行,定位到第一处错误。 489 | 2. 键入 x 以删除第一个不要的字符。 490 | 3. 现在 键入 u 以恢复最后执行的命令。 491 | 4. 这次用x命令修复该行的所有错误。 492 | 5. 现在键入一个大写的 U 以回到行的原始状态。 493 | 6。现在按几次 u 以恢复U 和之间的命令。 494 | 7. 现在 按几次 CTRL+R(按住CTRL同时敲击R),以撤消恢复命令(与u命令相反)。 495 | 496 | ---> Fiix the errors oon thhis line and reeplace them witth undo. 497 | 498 | 8. These are very useful commands. Now move on to the Lesson 2 Summary. 499 | 8. 这些都是非常有用的命令。现在移步到第2课的总结。 500 | 501 | 502 | 503 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 504 | Lesson 2 SUMMARY 505 | 第2课总结 506 | 507 | 508 | 1. To delete from the cursor up to the next word type: dw 509 | 删除光标到下一个单词: dw 510 | 2. To delete from the cursor to the end of a line type: d$ 511 | 删除光标到行尾: d$ 512 | 3. To delete a whole line type: dd 513 | 删除整行: dd 514 | 515 | 4. To repeat a motion prepend it with a number: 2w 516 | 预置数字以重复对象: 2w 517 | 5. The format for a change command is: 518 | operator [number] motion 519 | where: 520 | operator - is what to do, such as d for delete 521 | [number] - is an optional count to repeat the motion 522 | motion - moves over the text to operate on, such as w (word), 523 | $ (to the end of line), etc. 524 | 更改命令的格式: 525 | 操作码 [数字] 对象 526 | 527 | 6. To move to the start of the line use a zero: 0 528 | 用0移动到行首: 0 529 | 530 | 7. To undo previous actions, type: u (lowercase u) 531 | To undo all the changes on a line, type: U (capital U) 532 | To undo the undo's, type: CTRL-R 533 | 恢复之前的动作,键入: u (小写) 534 | 恢复对一行的所有改变,键入:U(大写) 535 | 恢复恢复,键入: CTRL-R 536 | 537 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 538 | Lesson 3.1: THE PUT COMMAND 539 | 3.1节:PUT命令 540 | 541 | 542 | ** Type p to put previously deleted text after the cursor. ** 543 | **输入 p 以在光标处粘贴先前删除的文本.** 544 | 545 | 1. Move the cursor to the first ---> line below. 546 | 移动光标到以下以--->标记的行。 547 | 548 | 2. Type dd to delete the line and store it in a Vim register. 549 | 输入 dd 以删除该行,该行会被存储至VIM寄存器中。 550 | 551 | 3. Move the cursor to the c) line, ABOVE where the deleted line should go. 552 | 移动光标到c)行,即被删除行要到达的前行。 553 | 554 | 4. Type p to put the line below the cursor. 555 | 键入 p 将那行粘贴到光标之下。 556 | 557 | 5. Repeat steps 2 through 4 to put all the lines in correct order. 558 | 重复步骤2到4以粘贴所有的行到正确的位置。 559 | 560 | ---> d) Can you learn too? 561 | ---> b) Violets are blue, 562 | ---> c) Intelligence is learned, 563 | ---> a) Roses are red, 564 | 565 | 566 | 567 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 568 | Lesson 3.2: THE REPLACE COMMAND 569 | 3.2节:替换命令 570 | 571 | 572 | ** Type rx to replace the character at the cursor with x . ** 573 | **键入 rx 以替换光标处的字符。** 574 | 575 | 1. Move the cursor to the first line below marked --->. 576 | 移动光标到以--->标记的行。 577 | 578 | 2. Move the cursor so that it is on top of the first error. 579 | 移动光标到第一个错误。 580 | 581 | 3. Type r and then the character which should be there. 582 | 键入 r和要更正的字符。 583 | 584 | 4. Repeat steps 2 and 3 until the first line is equal to the second one. 585 | 重复步骤2和3,直到一二行相同。 586 | 587 | ---> Whan this lime was tuoed in, someone presswd some wrojg keys! 588 | ---> When this line was typed in, someone pressed some wrong keys! 589 | 590 | 5. Now move on to Lesson 3.3. 591 | 现在移动到3.3节吧。 592 | 593 | NOTE: Remember that you should be learning by doing, not memorization. 594 | 注:记住你应该学会做而非记。 595 | 596 | 597 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 598 | Lesson 3.3: THE CHANGE OPERATOR 599 | 3.3:变更操作码 600 | 601 | 602 | ** To change until the end of a word, type ce . ** 603 | **要变更光标到词尾,键入:ce。** 604 | 605 | 1. Move the cursor to the first line below marked --->. 606 | 移动光标到以--->标记的行。 607 | 608 | 2. Place the cursor on the u in lubw. 609 | 定位光标至 lubw 的 u 上。 610 | 611 | 3. Type ce and the correct word (in this case, type ine ). 612 | 键入 ce 和 正确的单词(本例中,应该键入 ceine). 613 | 614 | 4. Press and move to the next character that needs to be changed. 615 | 按,并移动到下一个需要更改的字符。 616 | 617 | 5. Repeat steps 3 and 4 until the first sentence is the same as the second. 618 | 重复步骤3和4,以使第一句同第二句相同。 619 | 620 | ---> This lubw has a few wptfd that mrrf changing usf the change operator. 621 | ---> This line has a few words that need changing using the change operator. 622 | 623 | Notice that ce deletes the word and places you in Insert mode. 624 | 注意,ce 是删除单词并定位到插入模式(译者:其实后面的e就是对象,而前面的 c是操作码) 625 | 626 | 627 | 628 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 629 | Lesson 3.4: MORE CHANGES USING c 630 | 3.4节:其它的c更改命令 631 | 632 | 633 | ** The change operator is used with the same motions as delete. ** 634 | ** 同delete 命令一样,更改操作码也使用相同的对象。 635 | 636 | 1. The change operator works in the same way as delete. The format is: 637 | 638 | c [number] motion 639 | 更改操作码的用法与删除操作码相同,格式为: 640 | c [number] motion 641 | 642 | 2. The motions are the same, such as w (word) and $ (end of line). 643 | 所有的对象是相同的,例如w(单词)、$(行尾)。 644 | 645 | 3. Move to the first line below marked --->. 646 | 移动到以下以--->标记的第一行。 647 | 648 | 4. Move the cursor to the first error. 649 | 移动光标到第一处错误。 650 | 651 | 5. Type c$ and type the rest of the line like the second and press . 652 | 键入 c$ 和 余下的同第二行相同的字等符,并按下。 653 | 654 | ---> The end of this line needs some help to make it like the second. 655 | ---> The end of this line needs to be corrected using the c$ command. 656 | 657 | NOTE: You can use the Backspace key to correct mistakes while typing. 658 | 注: 在键入时,你可以使用退格以删除错误。 659 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 660 | Lesson 3 SUMMARY 661 | 第3课总结 662 | 663 | 664 | 1. To put back text that has just been deleted, type p . This puts the 665 | deleted text AFTER the cursor (if a line was deleted it will go on the 666 | line below the cursor). 667 | 要粘贴刚刚删除的文本,键入 p.这会把被删文本粘贴到光标之后(如果某行被删,它会被粘贴到光标之后的一行)。 668 | 669 | 2. To replace the character under the cursor, type r and then the 670 | character you want to have there. 671 | 要替换光标处的字符,键入 r 和要插入的字符。 672 | 673 | 3. The change operator allows you to change from the cursor to where the 674 | motion takes you. eg. Type ce to change from the cursor to the end of 675 | the word, c$ to change to the end of a line. 676 | 更改操作码允许你更改从光标到对象定义处。例如:键入 ce 以更改光标到词尾,键入c$会更改光标到行尾。 677 | 678 | 4. The format for change is: 679 | 680 | c [number] motion 681 | 更改的格式: 682 | c [number] motion 683 | 684 | Now go on to the next lesson. 685 | 现在进入 下一课吧。 686 | 687 | 688 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 689 | Lesson 4.1: CURSOR LOCATION AND FILE STATUS 690 | 4.1节:光标定位和文件状态 691 | 692 | ** Type CTRL-G to show your location in the file and the file status. 693 | Type G to move to a line in the file. ** 694 | **键入 CTRL-G 以显示你在文件中的位置和状态。 695 | 键入G 以移动到文件行尾。 696 | 697 | NOTE: Read this entire lesson before executing any of the steps!! 698 | 注:执行任何一步前请读完本课。 699 | 700 | 1. Hold down the Ctrl key and press g . We call this CTRL-G. 701 | A message will appear at the bottom of the page with the filename and the 702 | position in the file. Remember the line number for Step 3. 703 | 按住CTRL键,并键入 g. 我们称之为CTRL-G。 704 | 在页面的底部会呈现一个信息,指出文件名和当前文件位置。记住行号 705 | 以在第三步使用。 706 | 707 | NOTE: You may see the cursor position in the lower right corner of the screen 708 | This happens when the 'ruler' option is set (see :help 'ruler' ) 709 | 注: 你可能见到 处于屏幕右下角的光标 710 | 这发生在设置了‘ruler'选项时(见 :help 'ruler') 711 | 712 | 2. Press G to move you to the bottom of the file. 713 | Type gg to move you to the start of the file. 714 | 按 G 以移动到文件底。 715 | 键入 gg 以移动到文件首。 716 | 717 | 3. Type the number of the line you were on and then G . This will 718 | return you to the line you were on when you first pressed CTRL-G. 719 | 键入你之前所在 的行号,然后键入G。 720 | 这样你会返回到你之前,即你按CTRL-G时的那一行。 721 | 722 | 4. If you feel confident to do this, execute steps 1 through 3. 723 | 如果你有信心去做它,请执行1到3步。 724 | 725 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 726 | Lesson 4.2: THE SEARCH COMMAND 727 | 4.2节:搜索命令 728 | 729 | 730 | ** Type / followed by a phrase to search for the phrase. ** 731 | **按 / 并接一个要搜索的短语。** 732 | 733 | 1. In Normal mode type the / character. Notice that it and the cursor 734 | appear at the bottom of the screen as with the : command. 735 | 在正常模式,键入 / 字母。注意,像:命令一样,光标会出现在屏幕底 736 | 737 | 2. Now type 'errroor' . This is the word you want to search for. 738 | 现在,键入 'errroor'.这是你想要搜索的单词。 739 | 3. To search for the same phrase again, simply type n . 740 | To search for the same phrase in the opposite direction, type N . 741 | 想再次搜索相同的短语,简单的键入 n. 742 | 想再次搜索相同的短语并以相反的方向,键入 N. 743 | 744 | 4. To search for a phrase in the backward direction, use ? instead of / . 745 | 要反向搜索一个短语,使用?替换/. 746 | 747 | 5. To go back to where you came from press CTRL-O (Keep Ctrl down while 748 | pressing the letter o). Repeat to go back further. CTRL-I goes forward. 749 | 要返回之前的位置,键入 CTRL-O(按住 CTRL时,按下字母o).重复几次回到 750 | 更早的那刻。CTRL-I是向前移动。 751 | 752 | ---> "errroor" is not the way to spell error; errroor is an error. 753 | NOTE: When the search reaches the end of the file it will continue at the 754 | start, unless the 'wrapscan' option has been reset. 755 | 注: 当搜索到达文件尾时,它会从文件头开始搜索,除非’wrapscan'选项被设置了。 756 | 757 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 758 | Lesson 4.3: MATCHING PARENTHESES SEARCH 759 | 4.3节:括号匹配搜索 760 | 761 | 762 | ** Type % to find a matching ),], or } . ** 763 | **键入 % 以找到所匹配的),],or }.** 764 | 765 | 1. Place the cursor on any (, [, or { in the line below marked --->. 766 | 在以--->标记的行中,将光标定位到任一的(,[,{. 767 | 768 | 2. Now type the % character. 769 | 现在按下 %字符。 770 | 771 | 3. The cursor will move to the matching parenthesis or bracket. 772 | 将光标移动到匹配的括号上。 773 | 774 | 4. Type % to move the cursor to the other matching bracket. 775 | 按 % 以移动光标到其它的匹配括号。 776 | 777 | 5. Move the cursor to another (,),[,],{ or } and see what % does. 778 | 移动光标到 另外的(,),[,],{ or },看看 % 是怎么做的。 779 | 780 | ---> This ( is a test line with ('s, ['s ] and {'s } in it. )) 781 | 782 | 783 | NOTE: This is very useful in debugging a program with unmatched parentheses! 784 | 注:在高度程序的非匹配括号是这个是相当有用的。 785 | 786 | 787 | 788 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 789 | Lesson 4.4: THE SUBSTITUTE COMMAND 790 | 4.4:替换命令 791 | 792 | 793 | ** Type :s/old/new/g to substitute 'new' for 'old'. ** 794 | **键入 :s/old/new/g 以用’new'替换‘old’。** 795 | 796 | 1. Move the cursor to the line below marked --->. 797 | 移动光标到以下以--->标记的行。 798 | 799 | 2. Type :s/thee/the . Note that this command only changes the 800 | first occurrence of "thee" in the line. 801 | 键入 :s/thee/the .注意此命令仅会更改本行的第一例"thee". 802 | 803 | 3. Now type :s/thee/the/g . Adding the g flag means to substitute 804 | globally in the line, change all occurrences of "thee" in the line. 805 | 现在 键入 :s/three/the/g. 加入的 g 标志 意味着 会替换本行所有的 806 | “thee". 807 | 808 | ---> thee best time to see thee flowers is in thee spring. 809 | 810 | 811 | 4. To change every occurrence of a character string between two lines, 812 | type :#,#s/old/new/g where #,# are the line numbers of the range 813 | of lines where the substitution is to be done. 814 | Type :%s/old/new/g to change every occurrence in the whole file. 815 | Type :%s/old/new/gc to find every occurrence in the whole file, 816 | with a prompt whether to substitute or not. 817 | 要更改两行间的所有的匹配字符串: 818 | type :#,#s/old/new/g 其中,#,#是要更改的行号的范围 819 | Type :%s/old/new/g 更改全文件中的所有事件。 820 | Type :%s/old/new/gc 更改全文件中的所有事件,并给出替换与否的提示。 821 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 822 | Lesson 4 SUMMARY 823 | 第4课总结 824 | 825 | 1. CTRL-G displays your location in the file and the file status. 826 | G moves to the end of the file. 827 | number G moves to that line number. 828 | gg moves to the first line. 829 | CTRL-G 显示 当前文件位置和状态。 830 | G 移动到文件尾。 831 | 数字 G 移动到某行。 832 | gg 移动到文件头。 833 | 834 | 2. Typing / followed by a phrase searches FORWARD for the phrase. 835 | Typing ? followed by a phrase searches BACKWARD for the phrase. 836 | After a search type n to find the next occurrence in the same direction 837 | or N to search in the opposite direction. 838 | CTRL-O takes you back to older positions, CTRL-I to newer positions. 839 | 键入 / ,接上要向前搜索的短语。 840 | 键入 ? 接上要向后搜索的短语 841 | 搜索后,按n 以相同的方向搜索下一事件,按N以相反的方向搜索。 842 | CTRL-O 使你返回到以前的位置,CTRL-I 回到以后的位置 。 843 | 844 | 3. Typing % while the cursor is on a (,),[,],{, or } goes to its match. 845 | 键入 % 时括号上的光标会匹配自己的括号。 846 | 847 | 4. To substitute new for the first old in a line type :s/old/new 848 | To substitute new for all 'old's on a line type :s/old/new/g 849 | To substitute phrases between two line #'s type :#,#s/old/new/g 850 | To substitute all occurrences in the file type :%s/old/new/g 851 | To ask for confirmation each time add 'c' :%s/old/new/gc 852 | 在一行中以new替换old. :s/old/new 853 | 在一行中以new替换所有的old :s/old/new/g 854 | 在#到#两行间,以new 替换所有的old :#,#s/old/new/g 855 | 替换文件中的所有事件 :%s/old/new/g 856 | 每次替换前确认,增加‘c’' :%s/old/new/gc 857 | 858 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 859 | Lesson 5.1: HOW TO EXECUTE AN EXTERNAL COMMAND 860 | 5.1节:怎样执行外部命令 861 | 862 | 863 | ** Type :! followed by an external command to execute that command. ** 864 | ** 按 :! 并加上要执行的外部命令。×× 865 | 1. Type the familiar command : to set the cursor at the bottom of the 866 | screen. This allows you to enter a command-line command. 867 | 键入类似的命令: 使光标处于屏幕底。这允许你键入一个命令行。 868 | 869 | 2. Now type the ! (exclamation point) character. This allows you to 870 | execute any external shell command. 871 | 现在键入 ! 字符。这允许你执行一个任何外部的shell命令 872 | 873 | 3. As an example type ls following the ! and then hit . This 874 | will show you a listing of your directory, just as if you were at the 875 | shell prompt. Or use :!dir if ls doesn't work. 876 | 作为一个例子,键入 ls 接一个!,然后敲击.这会显示一个你的目录, 877 | 就像你在一个shell提示符一样。或者 使用 :!dir (如果 ls不起作用的话)。 878 | 879 | NOTE: It is possible to execute any external command this way, also with 880 | arguments. 881 | 注: 通过这种方式执行任何的外部命令是可能的,同样可以跟参数。 882 | 883 | NOTE: All : commands must be finished by hitting 884 | From here on we will not always mention it. 885 | 注: 所有的 : 命令必须以敲击结束。 886 | 从这里开始,我们不会问题提及这些问题。 887 | 888 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 889 | Lesson 5.2: MORE ON WRITING FILES 890 | 5.2节:其它的写文件命令 891 | 892 | ** To save the changes made to the text, type :w FILENAME. ** 893 | **要保存对文本作的改动,键入 :w FILENAME.** 894 | 895 | 1. Type :!dir or :!ls to get a listing of your directory. 896 | You already know you must hit after this. 897 | 键入 :!dir or :!ls 以得到你的目录的清单。 898 | 你已经 知道了你必须在这句后 敲击. 899 | 2. Choose a filename that does not exist yet, such as TEST. 900 | 选择一个不存在的文件名,如TEST。 901 | 902 | 3. Now type: :w TEST (where TEST is the filename you chose.) 903 | 现在 键入 : :w TEST (其中的TEST是你选择的文件名)。 904 | 905 | 4. This saves the whole file (the Vim Tutor) under the name TEST. 906 | To verify this, type :!dir or :!ls again to see your directory. 907 | 这会以TEST的名字 保存全部文件(即这个 VIM教程)。 908 | 要确认之,请键入 :!dir or :!ls 以查看你的目录。 909 | 910 | NOTE: If you were to exit Vim and start it again with vim TEST , the file 911 | would be an exact copy of the tutor when you saved it. 912 | 注:如果你之前退出了VIM并以vim TEST再次启动了它,这个文件就会是你保存时的教 913 | 程的副本。 914 | 915 | 5. Now remove the file by typing (MS-DOS): :!del TEST 916 | or (Unix): :!rm TEST 917 | 现在键入以下命令删除这个文件: 918 | (MS-DOS): :!del TEST 919 | or (Unix): :!rm TEST 920 | 921 | 922 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 923 | Lesson 5.3: SELECTING TEXT TO WRITE 924 | 5.3节:选择要写的文本 925 | 926 | ** To save part of the file, type v motion :w FILENAME ** 927 | ** 要保存部分文件,键入 v 对象 :w FILENAME ** 928 | 929 | 1. Move the cursor to this line. 930 | 移动光标到此行。 931 | 932 | 2. Press v and move the cursor to the fifth item below. Notice that the 933 | text is highlighted. 934 | 按 v 并移动 光标到 以下的第5项。 注意这些文本会珵高亮。 935 | 936 | 3. Press the : character. At the bottom of the screen :'<,'> will appear. 937 | 按 :字符。在屏幕底会显示 :'<,'> will appear. 938 | 939 | 4. Type w TEST , where TEST is a filename that does not exist yet. Verify 940 | that you see :'<,'>w TEST before you press Enter. 941 | 按 w TEST ,其中 TEST 是一个不存在 的文件。 942 | 确认你按前你看到了:'<,'>w TEST. 943 | 944 | 5. Vim will write the selected lines to the file TEST. Use :!dir or !ls 945 | to see it. Do not remove it yet! We will use it in the next lesson. 946 | vim 会把选定的行进文件TEST中,使用 :!dir or !ls 作检查。先别删除它! 947 | 我们会下节使用它。 948 | 949 | NOTE: Pressing v starts Visual selection. You can move the cursor around 950 | to make the selection bigger or smaller. Then you can use an operator 951 | to do something with the text. For example, d deletes the text. 952 | 注: 按下v 开始选择选择。你可以将光标移动到其它地方以使选择的区变大或者 变小。 953 | 然后你可使用操作码对文本做一些事。比如,d 删除文件。 954 | 955 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 956 | Lesson 5.4: RETRIEVING AND MERGING FILES 957 | 5.4节:恢复和合并文件 958 | 959 | 960 | ** To insert the contents of a file, type :r FILENAME ** 961 | ** 要插入一个文件的内容键入:r FILENAME ** 962 | 963 | 1. Place the cursor just above this line. 964 | 965 | NOTE: After executing Step 2 you will see text from Lesson 5.3. Then move 966 | DOWN to see this lesson again. 967 | 只需将光标放到这一行。 968 | 注: 执行第二步后你会看到5.3节的内容。然后下移并再次查看这节。 969 | 970 | 2. Now retrieve your TEST file using the command :r TEST where TEST is 971 | the name of the file you used. 972 | The file you retrieve is placed below the cursor line. 973 | 现在 恢复 你的TEST文件,使用命令 :r TEST 其中,TEST 是你使用的文件。 974 | 你要恢复的文件将被放置在光标行下面。 975 | 976 | 3. To verify that a file was retrieved, cursor back and notice that there 977 | are now two copies of Lesson 5.3, the original and the file version. 978 | 要确认文件被恢复了,用光标返回,注意这里有两5.3节的副本,原本的文件版。 979 | 980 | NOTE: You can also read the output of an external command. For example, 981 | :r !ls reads the output of the ls command and puts it below the 982 | cursor. 983 | 注: 你可能会阅读外部命令的输出。如 :r !ls 读入ls命令的输出并将其放置到 984 | 光标下。` 985 | 986 | 987 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 988 | Lesson 5 SUMMARY 989 | 第5课总结 990 | 991 | 992 | 1. :!command executes an external command. 993 | 994 | Some useful examples are: 995 | (MS-DOS) (Unix) 996 | :!dir :!ls - shows a directory listing. 997 | :!del FILENAME :!rm FILENAME - removes file FILENAME. 998 | 999 | :!command 执行外部命令 1000 | 1001 | 一些有用的例子: 1002 | (MS-DOS) (Unix) 1003 | :!dir :!ls - 显示目录清单 1004 | :!del FILENAME :!rm FILENAME - 移除 FILENAME文件。 1005 | 1006 | 2. :w FILENAME writes the current Vim file to disk with name FILENAME. 1007 | :w FILENAME 将当前的vim 文件以FILENAME 文件名写进磁盘 。 1008 | 1009 | 3. v motion :w FILENAME saves the Visually selected lines in file 1010 | FILENAME. 1011 | v 对象 :w FILENAME 保存选定选择行到FILENAME 文件。 1012 | 1013 | 4. :r FILENAME retrieves disk file FILENAME and puts it below the 1014 | cursor position. 1015 | :r FILENAME 恢复磁盘文件FILENAME到光标下。 1016 | 1017 | 5. :r !dir reads the output of the dir command and puts it below the 1018 | cursor position. 1019 | :r !dir 读取dir命令的输出并粘贴到光标下。 1020 | 1021 | 1022 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1023 | Lesson 6.1: THE OPEN COMMAND 1024 | 6.1节:OPEN 命令 1025 | 1026 | 1027 | ** Type o to open a line below the cursor and place you in Insert mode. ** 1028 | ** 键入 o 以在光标打开一行,并置于插入模式。** 1029 | 1030 | 1. Move the cursor to the line below marked --->. 1031 | 移动光标到以--->标记的行。 1032 | 1033 | 2. Type the lowercase letter o to open up a line BELOW the cursor and place 1034 | you in Insert mode. 1035 | 键入 小写字母 o 以在光标下插入一行,并置于插入模式。 1036 | 1037 | 3. Now type some text and press to exit Insert mode. 1038 | 现在 键入 一些文本,并按以退出插入模式。 1039 | 1040 | ---> After typing o the cursor is placed on the open line in Insert mode. 1041 | 1042 | 4. To open up a line ABOVE the cursor, simply type a capital O , rather 1043 | than a lowercase o. Try this on the line below. 1044 | 要在光标前插入一行,只需键入 大写字母 O,而非小写字母 o,在下一行试试。 1045 | 1046 | ---> Open up a line above this by typing O while the cursor is on this line. 1047 | 1048 | 1049 | 1050 | 1051 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1052 | Lesson 6.2: THE APPEND COMMAND 1053 | 6.2: 追加命令 1054 | 1055 | ** Type a to insert text AFTER the cursor. ** 1056 | **键入 a 以在光标后插入文本。** 1057 | 1058 | 1. Move the cursor to the start of the line below marked --->. 1059 | 移动 下面以--->标记的行首。 1060 | 1061 | 2. Press e until the cursor is on the end of li . 1062 | 按 e 直到 光标在li 尾。 1063 | 1064 | 3. Type an a (lowercase) to append text AFTER the cursor. 1065 | 铵 一个 a(小写) 以追加文本到光标后。 1066 | 1067 | 4. Complete the word like the line below it. Press to exit Insert 1068 | mode. 1069 | 按照下一行完成这个单词。按退出插入模式。 1070 | 1071 | 5. Use e to move to the next incomplete word and repeat steps 3 and 4. 1072 | 使用 e 移动到未完成的单词,并重复步骤3和4. 1073 | 1074 | ---> This li will allow you to pract appendi text to a line. 1075 | ---> This line will allow you to practice appending text to a line. 1076 | 1077 | NOTE: a, i and A all go to the same Insert mode, the only difference is where 1078 | the characters are inserted. 1079 | 注: a,i 和A 都会进入插入模式,仅有的不同是字符在哪里插入。 1080 | 1081 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1082 | Lesson 6.3: ANOTHER WAY TO REPLACE 1083 | 6.3节: 以别一种方式替换 1084 | 1085 | 1086 | ** Type a capital R to replace more than one character. ** 1087 | ** 键入 大写 R 以替换 更多的字符而非一个。** 1088 | 1089 | 1. Move the cursor to the first line below marked --->. Move the cursor to 1090 | the beginning of the first xxx . 1091 | 移动光标到以---》标记的第一行。移动光标到第一个XXX。 1092 | 1093 | 2. Now press R and type the number below it in the second line, so that it 1094 | replaces the xxx . 1095 | 现在 按下 R 并键入 在第二行显示的数字,以其替换xxx. 1096 | 1097 | 3. Press to leave Replace mode. Notice that the rest of the line 1098 | remains unmodified. 1099 | 按下 以 离开替换模式。注意 剩余的行仍没有改变。 1100 | 1101 | 4. Repeat the steps to replace the remaining xxx. 1102 | 重复以上步骤以替换剩余的XXX。 1103 | 1104 | ---> Adding 123 to xxx gives you xxx. 1105 | ---> Adding 123 to 456 gives you 579. 1106 | 1107 | NOTE: Replace mode is like Insert mode, but every typed character deletes an 1108 | existing character. 1109 | 注: 替换模式下类似于插入模式,但是键入字符会删除已经存在的字符。 1110 | 1111 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1112 | Lesson 6.4: COPY AND PASTE TEXT 1113 | 6.4: 复制粘贴文本 1114 | 1115 | 1116 | ** Use the y operator to copy text and p to paste it ** 1117 | ** 用y 操作码来复制文本,以 p 粘贴此文本.** 1118 | 1119 | 1. Go to the line marked with ---> below and place the cursor after "a)". 1120 | 移动到以--->标记的行并定位到“a)”后。 1121 | 1122 | 2. Start Visual mode with v and move the cursor to just before "first". 1123 | 以v 开启选择模式,移动光标到“first”前。 1124 | 1125 | 3. Type y to yank (copy) the highlighted text. 1126 | 按 y 以复制高亮的文本。 1127 | 1128 | 4. Move the cursor to the end of the next line: j$ 1129 | 移动 光标到下一行的:j$ 1130 | 1131 | 5. Type p to put (paste) the text. Then type: a second . 1132 | 按p 以粘贴文本,然后键入:a second . 1133 | 1134 | 6. Use Visual mode to select " item.", yank it with y , move to the end of 1135 | the next line with j$ and put the text there with p . 1136 | 使用选择模式以选择” item。“,以y复制之,以j$移动到下行并以p粘贴到那里。 1137 | 1138 | ---> a) this is the first item. 1139 | b) 1140 | 1141 | NOTE: you can also use y as an operator; yw yanks one word. 1142 | 注: 你可能会使用y 作操作码;yw 复制一个单词。 1143 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1144 | Lesson 6.5: SET OPTION 1145 | 6.5节:设置选项 1146 | 1147 | 1148 | ** Set an option so a search or substitute ignores case ** 1149 | ** 设置搜索和替换时忽略大小写的选项** 1150 | 1151 | 1. Search for 'ignore' by entering: /ignore 1152 | Repeat several times by pressing n . 1153 | 搜索’ignore‘ ,键入 : /ignore 1154 | 重复按n几次。 1155 | 1156 | 2. Set the 'ic' (Ignore case) option by entering: :set ic 1157 | 设置 ’ic‘(忽略大小写)选项,键入: :set ic 1158 | 1159 | 3. Now search for 'ignore' again by pressing n 1160 | Notice that Ignore and IGNORE are now also found. 1161 | 现在 以n再次搜索'ignore'. 1162 | 注意,Ignore and IGNORE都可以被搜到。 1163 | 1164 | 4. Set the 'hlsearch' and 'incsearch' options: :set hls is 1165 | 设置选项'hlsearch' and 'incsearch': set hls is 1166 | 1167 | 5. Now type the search command again and see what happens: /ignore 1168 | 同在键入搜索命令,看看发生 了什么: /ignore 1169 | 1170 | 6. To disable ignoring case enter: :set noic 1171 | 要禁止忽略大小写,键入: :set noic 1172 | 1173 | NOTE: To remove the highlighting of matches enter: :nohlsearch 1174 | 注意: 要删除高亮匹配,键入: :nohlsearch 1175 | NOTE: If you want to ignore case for just one search command, use \c 1176 | in the phrase: /ignore\c 1177 | 注: 如果 你只是想在某次搜索命令时忽略大小写,在短语后加上\c: /ignore\c 1178 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1179 | Lesson 6 SUMMARY 1180 | 第6课总结 1181 | 1182 | 1. Type o to open a line BELOW the cursor and start Insert mode. 1183 | Type O to open a line ABOVE the cursor. 1184 | 按o 以插入一行,在光标后,并进入插入模式。 1185 | 按O 以在光标前插入一行。 1186 | 1187 | 2. Type a to insert text AFTER the cursor. 1188 | Type A to insert text after the end of the line. 1189 | 按a 以在光标后插入文本。 1190 | 按A在行尾插入文本。 1191 | 1192 | 3. The e command moves to the end of a word. 1193 | e命令使光标移动到单词尾。 1194 | 1195 | 4. The y operator yanks (copies) text, p puts (pastes) it. 1196 | y操作码 复制文本,p 粘贴此文本。 1197 | 1198 | 5. Typing a capital R enters Replace mode until is pressed. 1199 | 调入大写字母R,进入替换模式,直到按下。 1200 | 1201 | 6. Typing ":set xxx" sets the option "xxx". Some options are: 1202 | 'ic' 'ignorecase' ignore upper/lower case when searching 1203 | 'is' 'incsearch' show partial matches for a search phrase 1204 | 'hls' 'hlsearch' highlight all matching phrases 1205 | You can either use the long or the short option name. 1206 | 1207 | 键入":set xxx" 以设置选项 "xxx". 一些选项: 1208 | 'ic' 'ignorecase' 搜索时忽略大小写 1209 | 'is' 'incsearch' 部分显示匹配的搜索短语。 1210 | 'hls' 'hlsearch' 高亮所有匹配的短语 1211 | 你可选用长的或者短的选项名。 1212 | 1213 | 7. Prepend "no" to switch an option off: :set noic 1214 | 前置”no"以关闭选项: :set noic 1215 | 1216 | 1217 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1218 | Lesson 7.1: GETTING HELP 1219 | 7.1节:使用帮助 1220 | 1221 | 1222 | ** Use the on-line help system ** 1223 | **使用在线帮助系统** 1224 | 1225 | Vim has a comprehensive on-line help system. To get started, try one of 1226 | these three: 1227 | - press the key (if you have one) 1228 | - press the key (if you have one) 1229 | - type :help 1230 | vim 有一个广泛的在线帮助系统。要启用之,可试试这三种之一: 1231 | - 按 (如果你有) 1232 | - 按 (如果你有) 1233 | - 按 :help 1234 | 1235 | Read the text in the help window to find out how the help works. 1236 | Type CTRL-W CTRL-W to jump from one window to another. 1237 | Type :q to close the help window. 1238 | 阅读help窗口以查看help是如何进行的。 1239 | Type CTRL-W CTRL-W 从一个窗口跳转到另一个窗口。 1240 | Type :q 关闭帮助 窗口。 1241 | 1242 | You can find help on just about any subject, by giving an argument to the 1243 | ":help" command. Try these (don't forget pressing ): 1244 | 1245 | :help w 1246 | :help c_CTRL-D 1247 | :help insert-index 1248 | :help user-manual 1249 | 你可以通过为":help"给一个参数找到任何主题的帮助,试试这些(别忘了) 1250 | :help w 1251 | :help c_CTRL-D 1252 | :help insert-index 1253 | :help user-manual 1254 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1255 | Lesson 7.2: CREATE A STARTUP SCRIPT 1256 | 7.2节:创建启动脚本 1257 | 1258 | 1259 | ** Enable Vim features ** 1260 | **启用VIM特性** 1261 | Vim has many more features than Vi, but most of them are disabled by 1262 | default. To start using more features you have to create a "vimrc" file. 1263 | VIM 拥有比vi更多的特性,但是大多数是被默认禁止的。要使用更多的 1264 | 特性,你可创建“vimrc”文件。 1265 | 1266 | 1. Start editing the "vimrc" file. This depends on your system: 1267 | :e ~/.vimrc for Unix 1268 | :e $VIM/_vimrc for MS-Windows 1269 | 开始编辑“vimrc”文件,这依赖于你的系统。 1270 | :e ~/.vimrc for Unix 1271 | :e $VIM/_vimrc for MS-Windows 1272 | 2. Now read the example "vimrc" file contents: 1273 | :r $VIMRUNTIME/vimrc_example.vim 1274 | 现在阅读下“vimrc”文件的例子: 1275 | :r $VIMRUNTIME/vimrc_example.vim 1276 | 1277 | 3. Write the file with:保存文件 1278 | :w 1279 | 1280 | The next time you start Vim it will use syntax highlighting. 1281 | You can add all your preferred settings to this "vimrc" file. 1282 | For more information type :help vimrc-intro 1283 | 下次,你启动VIM后,它会使语法高亮,你可以在“vimrc”中添加所有你喜欢的 1284 | 设置。 1285 | 更多信息请键入 :help vimrc-intro 1286 | 1287 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1288 | Lesson 7.3: COMPLETION 1289 | 7.3节:补齐 1290 | 1291 | ** Command line completion with CTRL-D and ** 1292 | ××使用CTRL-D和使命令行补齐×× 1293 | 1294 | 1. Make sure Vim is not in compatible mode: :set nocp 1295 | 确保VIM 处于非兼容模式: :set nocp 1296 | 1297 | 2. Look what files exist in the directory: :!ls or :!dir 1298 | 看看目录下有什么文件存在: :!ls or :!dir 1299 | 1300 | 3. Type the start of a command: :e 1301 | 键入命令的开始部分: :e 1302 | 1303 | 4. Press CTRL-D and Vim will show a list of commands that start with "e". 1304 | 按 CTRL-D ,VIM会显示以“e”开头的清单。 1305 | 1306 | 5. Press and Vim will complete the command name to ":edit". 1307 | 按下,VIM会以“:edit"补齐命令名。 1308 | 1309 | 6. Now add a space and the start of an existing file name: :edit FIL 1310 | 现在 添加一个空格和己存的文件名头部: :edit FIL 1311 | 1312 | 7. Press . Vim will complete the name (if it is unique). 1313 | 按,vim会完成余下的文件名(如果它是独有的话)。 1314 | 1315 | NOTE: Completion works for many commands. Just try pressing CTRL-D and 1316 | . It is especially useful for :help . 1317 | 注:补齐针对大多数命令有效,只需按CTRL-R和.特别是对 :help 非常有用 。 1318 | 1319 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1320 | Lesson 7 SUMMARY 1321 | 第七课总结 1322 | 1323 | 1. Type :help or press or to open a help window. 1324 | 键入 :help 或 以打开帮助窗口 1325 | 1326 | 2. Type :help cmd to find help on cmd . 1327 | 键入 :help cmd 以找出关于cmd的帮助 。 1328 | 1329 | 3. Type CTRL-W CTRL-W to jump to another window 1330 | 键入 CTRL-W 以跳转到另一窗口。 1331 | 1332 | 4. Type :q to close the help window 1333 | 键入 :q 以关闭帮助窗口。 1334 | 1335 | 5. Create a vimrc startup script to keep your preferred settings. 1336 | 创建 vimrc 启动脚本以保存你喜欢的设置。 1337 | 1338 | 6. When typing a : command, press CTRL-D to see possible completions. 1339 | Press to use one completion. 1340 | 当键入 :command 时,按下CTRL-D 以查看可能的补齐。 1341 | 按使用其中一个补齐。 1342 | 1343 | 1344 | 1345 | 1346 | 1347 | 1348 | 1349 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1350 | 1351 | This concludes the Vim Tutor. It was intended to give a brief overview of 1352 | the Vim editor, just enough to allow you to use the editor fairly easily. 1353 | It is far from complete as Vim has many many more commands. Read the user 1354 | manual next: ":help user-manual". 1355 | 本文总结了vim教程。它原本给出了VIM编辑器的简短的概要,只能足以让你很容易地 1356 | 使用编辑器。这远没有完成,因为VIM在如此众多的命令。请阅读下面的用户手册: 1357 | :help user-manual 1358 | 1359 | For further reading and studying, this book is recommended: 1360 | Vim - Vi Improved - by Steve Oualline 1361 | Publisher: New Riders 1362 | The first book completely dedicated to Vim. Especially useful for beginners. 1363 | There are many examples and pictures. 1364 | See http://iccf-holland.org/click5.html 1365 | 1366 | 要进一步的阅读和学习,我们推荐这本书: 1367 | Vim - Vi Improved -作者Steve Oualline 1368 | 出版社:New Riders 1369 | 第一本书专门针对 Vim. 特别适合 新手. 1370 | 其中有许多实例和图示。 1371 | See http://iccf-holland.org/click5.html 1372 | 1373 | 1374 | This book is older and more about Vi than Vim, but also recommended: 1375 | Learning the Vi Editor - by Linda Lamb 1376 | Publisher: O'Reilly & Associates Inc. 1377 | It is a good book to get to know almost anything you want to do with Vi. 1378 | The sixth edition also includes information on Vim. 1379 | 1380 | 这本书比较老并且主要内容是VI而非vim,但是仍值得推荐: 1381 | Learning the Vi Editor - by Linda Lamb 1382 | 出版社: O'Reilly & Associates Inc. 1383 | 它是一本能告诉你你想利用VI做的几乎所有事情的好书。 1384 | 此书的第三版也包含了有关VIM的内容。 1385 | 1386 | 1387 | This tutorial was written by Michael C. Pierce and Robert K. Ware, 1388 | Colorado School of Mines using ideas supplied by Charles Smith, 1389 | Colorado State University. E-mail: bware@mines.colorado.edu. 1390 | Modified for Vim by Bram Moolenaar. 1391 | 1392 | 本教程由科罗拉多矿业学院的Michael C. Pierce 和 Robert K. Ware编写,同时Charles Smith 提供了很多创意。 1393 | E-mail: bware@mines.colorado.edu. 1394 | Bram Moolenaar 为VIM对本教程作了修订。 1395 | 1396 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1397 | 下面是一些补充: 1398 | ===================================================== 1399 | CTRL+F:往下翻页 1400 | CTRL+B:往上翻页 1401 | 1402 | 行的拼接: 1403 | 在选择模式选中要拼接的行:ggvG 1404 | 输入: :'<,'>j 1405 | 注:普通的j用于拼接单行。 1406 | 列操作: 1407 | 选中全文的第一列 1408 | 按gg跳至开头 1409 | 按CTRL——V进入列选择状态:visula block 1410 | 按G到末尾 1411 | 将每行的第一列变为大写 1412 | 按U将选中内容变大写 1413 | 按u将选中内容变小写 1414 | 按~将大小翻转。 1415 | 列操作:在第行前加一个星号和空格: 1416 | 选中第一列 1417 | 按I进入插入状态 1418 | 输入:* 1419 | 选中前两列后按x,可时行列删除 1420 | 宏的录制:将所有偶数行后加入OK! 1421 | 按gg进入第一行 1422 | 按qm进入宏录制 1423 | 按j$进入第二行尾 1424 | 按aok!以输入ok! 1425 | 按返回 1426 | 按j到下一行 1427 | 按q结束宏录制 1428 | 宏的播放:(接上面的步骤) 1429 | 单次播放: 1430 | 按下@m,执行m寄存器中的宏 1431 | 可以发现第4行中的尾已经加入了ok! 1432 | 多次播放: 1433 | 按下100@m,这里重复播放100次宏。 1434 | 点号(重复上一次命令): 1435 | 将第行尾加一个感叹号 1436 | 按ggA!以在第一行添加感叹号 1437 | 按j以到下一行。 1438 | 按.表示重复前一个操作,即在执行A!以在行尾添加一个感叹号。 1439 | 反复按j.j.j.j.j. 1440 | :%s/$/!/g 1441 | 1442 | 1443 | 1444 | ========================.virc for beginners================== 1445 | 基本设置 1446 | set nocp 设置不兼容模式 1447 | set ru 打开状态栏标尺 1448 | set hls 搜索时高亮显示找到的文本 1449 | set is 递进搜索 1450 | syntax on 打开关键字上色 1451 | set backspace=indent,eol,start 1452 | set whichrap=b,s,<,>,[,] 1453 | h,l,~ 1454 | set sw=4 缩进尺寸4个空格 1455 | set ts=4 Tab宽度为4个字符 1456 | set et 将所有的TAB替换为空格 1457 | C/C++编码设置 1458 | set cin 自动缩进 1459 | set ai 还是自动缩进 1460 | set cino=:0g0t0(sus 1461 | set sm 显示括号匹配 1462 | 在console下粘贴版式的问题 1463 | :set paste 1464 | :set nopaste 1465 | = 命令重调格式 1466 | 断行设置 1467 | set lbr 不在单词中间断行 1468 | 图形界面与字符界面分别设置 1469 | if (has("gui_running")) 图形界面设置 1470 | set nowrap 不拆行 1471 | set guioptions+=b 水平流动条 1472 | colo torte 配色方案 1473 | else 字符界面设置 1474 | set wrap 拆行 1475 | colo ron 配色方案 1476 | endif 1477 | --------------------------------------------------------------------------------