Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
5601024df7 |
427
LICENSE
427
LICENSE
@ -1,427 +0,0 @@
|
|||||||
Attribution-ShareAlike 4.0 International
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
Creative Commons Corporation ("Creative Commons") is not a law firm and
|
|
||||||
does not provide legal services or legal advice. Distribution of
|
|
||||||
Creative Commons public licenses does not create a lawyer-client or
|
|
||||||
other relationship. Creative Commons makes its licenses and related
|
|
||||||
information available on an "as-is" basis. Creative Commons gives no
|
|
||||||
warranties regarding its licenses, any material licensed under their
|
|
||||||
terms and conditions, or any related information. Creative Commons
|
|
||||||
disclaims all liability for damages resulting from their use to the
|
|
||||||
fullest extent possible.
|
|
||||||
|
|
||||||
Using Creative Commons Public Licenses
|
|
||||||
|
|
||||||
Creative Commons public licenses provide a standard set of terms and
|
|
||||||
conditions that creators and other rights holders may use to share
|
|
||||||
original works of authorship and other material subject to copyright
|
|
||||||
and certain other rights specified in the public license below. The
|
|
||||||
following considerations are for informational purposes only, are not
|
|
||||||
exhaustive, and do not form part of our licenses.
|
|
||||||
|
|
||||||
Considerations for licensors: Our public licenses are
|
|
||||||
intended for use by those authorized to give the public
|
|
||||||
permission to use material in ways otherwise restricted by
|
|
||||||
copyright and certain other rights. Our licenses are
|
|
||||||
irrevocable. Licensors should read and understand the terms
|
|
||||||
and conditions of the license they choose before applying it.
|
|
||||||
Licensors should also secure all rights necessary before
|
|
||||||
applying our licenses so that the public can reuse the
|
|
||||||
material as expected. Licensors should clearly mark any
|
|
||||||
material not subject to the license. This includes other CC-
|
|
||||||
licensed material, or material used under an exception or
|
|
||||||
limitation to copyright. More considerations for licensors:
|
|
||||||
wiki.creativecommons.org/Considerations_for_licensors
|
|
||||||
|
|
||||||
Considerations for the public: By using one of our public
|
|
||||||
licenses, a licensor grants the public permission to use the
|
|
||||||
licensed material under specified terms and conditions. If
|
|
||||||
the licensor's permission is not necessary for any reason--for
|
|
||||||
example, because of any applicable exception or limitation to
|
|
||||||
copyright--then that use is not regulated by the license. Our
|
|
||||||
licenses grant only permissions under copyright and certain
|
|
||||||
other rights that a licensor has authority to grant. Use of
|
|
||||||
the licensed material may still be restricted for other
|
|
||||||
reasons, including because others have copyright or other
|
|
||||||
rights in the material. A licensor may make special requests,
|
|
||||||
such as asking that all changes be marked or described.
|
|
||||||
Although not required by our licenses, you are encouraged to
|
|
||||||
respect those requests where reasonable. More_considerations
|
|
||||||
for the public:
|
|
||||||
wiki.creativecommons.org/Considerations_for_licensees
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
Creative Commons Attribution-ShareAlike 4.0 International Public
|
|
||||||
License
|
|
||||||
|
|
||||||
By exercising the Licensed Rights (defined below), You accept and agree
|
|
||||||
to be bound by the terms and conditions of this Creative Commons
|
|
||||||
Attribution-ShareAlike 4.0 International Public License ("Public
|
|
||||||
License"). To the extent this Public License may be interpreted as a
|
|
||||||
contract, You are granted the Licensed Rights in consideration of Your
|
|
||||||
acceptance of these terms and conditions, and the Licensor grants You
|
|
||||||
such rights in consideration of benefits the Licensor receives from
|
|
||||||
making the Licensed Material available under these terms and
|
|
||||||
conditions.
|
|
||||||
|
|
||||||
|
|
||||||
Section 1 -- Definitions.
|
|
||||||
|
|
||||||
a. Adapted Material means material subject to Copyright and Similar
|
|
||||||
Rights that is derived from or based upon the Licensed Material
|
|
||||||
and in which the Licensed Material is translated, altered,
|
|
||||||
arranged, transformed, or otherwise modified in a manner requiring
|
|
||||||
permission under the Copyright and Similar Rights held by the
|
|
||||||
Licensor. For purposes of this Public License, where the Licensed
|
|
||||||
Material is a musical work, performance, or sound recording,
|
|
||||||
Adapted Material is always produced where the Licensed Material is
|
|
||||||
synched in timed relation with a moving image.
|
|
||||||
|
|
||||||
b. Adapter's License means the license You apply to Your Copyright
|
|
||||||
and Similar Rights in Your contributions to Adapted Material in
|
|
||||||
accordance with the terms and conditions of this Public License.
|
|
||||||
|
|
||||||
c. BY-SA Compatible License means a license listed at
|
|
||||||
creativecommons.org/compatiblelicenses, approved by Creative
|
|
||||||
Commons as essentially the equivalent of this Public License.
|
|
||||||
|
|
||||||
d. Copyright and Similar Rights means copyright and/or similar rights
|
|
||||||
closely related to copyright including, without limitation,
|
|
||||||
performance, broadcast, sound recording, and Sui Generis Database
|
|
||||||
Rights, without regard to how the rights are labeled or
|
|
||||||
categorized. For purposes of this Public License, the rights
|
|
||||||
specified in Section 2(b)(1)-(2) are not Copyright and Similar
|
|
||||||
Rights.
|
|
||||||
|
|
||||||
e. Effective Technological Measures means those measures that, in the
|
|
||||||
absence of proper authority, may not be circumvented under laws
|
|
||||||
fulfilling obligations under Article 11 of the WIPO Copyright
|
|
||||||
Treaty adopted on December 20, 1996, and/or similar international
|
|
||||||
agreements.
|
|
||||||
|
|
||||||
f. Exceptions and Limitations means fair use, fair dealing, and/or
|
|
||||||
any other exception or limitation to Copyright and Similar Rights
|
|
||||||
that applies to Your use of the Licensed Material.
|
|
||||||
|
|
||||||
g. License Elements means the license attributes listed in the name
|
|
||||||
of a Creative Commons Public License. The License Elements of this
|
|
||||||
Public License are Attribution and ShareAlike.
|
|
||||||
|
|
||||||
h. Licensed Material means the artistic or literary work, database,
|
|
||||||
or other material to which the Licensor applied this Public
|
|
||||||
License.
|
|
||||||
|
|
||||||
i. Licensed Rights means the rights granted to You subject to the
|
|
||||||
terms and conditions of this Public License, which are limited to
|
|
||||||
all Copyright and Similar Rights that apply to Your use of the
|
|
||||||
Licensed Material and that the Licensor has authority to license.
|
|
||||||
|
|
||||||
j. Licensor means the individual(s) or entity(ies) granting rights
|
|
||||||
under this Public License.
|
|
||||||
|
|
||||||
k. Share means to provide material to the public by any means or
|
|
||||||
process that requires permission under the Licensed Rights, such
|
|
||||||
as reproduction, public display, public performance, distribution,
|
|
||||||
dissemination, communication, or importation, and to make material
|
|
||||||
available to the public including in ways that members of the
|
|
||||||
public may access the material from a place and at a time
|
|
||||||
individually chosen by them.
|
|
||||||
|
|
||||||
l. Sui Generis Database Rights means rights other than copyright
|
|
||||||
resulting from Directive 96/9/EC of the European Parliament and of
|
|
||||||
the Council of 11 March 1996 on the legal protection of databases,
|
|
||||||
as amended and/or succeeded, as well as other essentially
|
|
||||||
equivalent rights anywhere in the world.
|
|
||||||
|
|
||||||
m. You means the individual or entity exercising the Licensed Rights
|
|
||||||
under this Public License. Your has a corresponding meaning.
|
|
||||||
|
|
||||||
|
|
||||||
Section 2 -- Scope.
|
|
||||||
|
|
||||||
a. License grant.
|
|
||||||
|
|
||||||
1. Subject to the terms and conditions of this Public License,
|
|
||||||
the Licensor hereby grants You a worldwide, royalty-free,
|
|
||||||
non-sublicensable, non-exclusive, irrevocable license to
|
|
||||||
exercise the Licensed Rights in the Licensed Material to:
|
|
||||||
|
|
||||||
a. reproduce and Share the Licensed Material, in whole or
|
|
||||||
in part; and
|
|
||||||
|
|
||||||
b. produce, reproduce, and Share Adapted Material.
|
|
||||||
|
|
||||||
2. Exceptions and Limitations. For the avoidance of doubt, where
|
|
||||||
Exceptions and Limitations apply to Your use, this Public
|
|
||||||
License does not apply, and You do not need to comply with
|
|
||||||
its terms and conditions.
|
|
||||||
|
|
||||||
3. Term. The term of this Public License is specified in Section
|
|
||||||
6(a).
|
|
||||||
|
|
||||||
4. Media and formats; technical modifications allowed. The
|
|
||||||
Licensor authorizes You to exercise the Licensed Rights in
|
|
||||||
all media and formats whether now known or hereafter created,
|
|
||||||
and to make technical modifications necessary to do so. The
|
|
||||||
Licensor waives and/or agrees not to assert any right or
|
|
||||||
authority to forbid You from making technical modifications
|
|
||||||
necessary to exercise the Licensed Rights, including
|
|
||||||
technical modifications necessary to circumvent Effective
|
|
||||||
Technological Measures. For purposes of this Public License,
|
|
||||||
simply making modifications authorized by this Section 2(a)
|
|
||||||
(4) never produces Adapted Material.
|
|
||||||
|
|
||||||
5. Downstream recipients.
|
|
||||||
|
|
||||||
a. Offer from the Licensor -- Licensed Material. Every
|
|
||||||
recipient of the Licensed Material automatically
|
|
||||||
receives an offer from the Licensor to exercise the
|
|
||||||
Licensed Rights under the terms and conditions of this
|
|
||||||
Public License.
|
|
||||||
|
|
||||||
b. Additional offer from the Licensor -- Adapted Material.
|
|
||||||
Every recipient of Adapted Material from You
|
|
||||||
automatically receives an offer from the Licensor to
|
|
||||||
exercise the Licensed Rights in the Adapted Material
|
|
||||||
under the conditions of the Adapter's License You apply.
|
|
||||||
|
|
||||||
c. No downstream restrictions. You may not offer or impose
|
|
||||||
any additional or different terms or conditions on, or
|
|
||||||
apply any Effective Technological Measures to, the
|
|
||||||
Licensed Material if doing so restricts exercise of the
|
|
||||||
Licensed Rights by any recipient of the Licensed
|
|
||||||
Material.
|
|
||||||
|
|
||||||
6. No endorsement. Nothing in this Public License constitutes or
|
|
||||||
may be construed as permission to assert or imply that You
|
|
||||||
are, or that Your use of the Licensed Material is, connected
|
|
||||||
with, or sponsored, endorsed, or granted official status by,
|
|
||||||
the Licensor or others designated to receive attribution as
|
|
||||||
provided in Section 3(a)(1)(A)(i).
|
|
||||||
|
|
||||||
b. Other rights.
|
|
||||||
|
|
||||||
1. Moral rights, such as the right of integrity, are not
|
|
||||||
licensed under this Public License, nor are publicity,
|
|
||||||
privacy, and/or other similar personality rights; however, to
|
|
||||||
the extent possible, the Licensor waives and/or agrees not to
|
|
||||||
assert any such rights held by the Licensor to the limited
|
|
||||||
extent necessary to allow You to exercise the Licensed
|
|
||||||
Rights, but not otherwise.
|
|
||||||
|
|
||||||
2. Patent and trademark rights are not licensed under this
|
|
||||||
Public License.
|
|
||||||
|
|
||||||
3. To the extent possible, the Licensor waives any right to
|
|
||||||
collect royalties from You for the exercise of the Licensed
|
|
||||||
Rights, whether directly or through a collecting society
|
|
||||||
under any voluntary or waivable statutory or compulsory
|
|
||||||
licensing scheme. In all other cases the Licensor expressly
|
|
||||||
reserves any right to collect such royalties.
|
|
||||||
|
|
||||||
|
|
||||||
Section 3 -- License Conditions.
|
|
||||||
|
|
||||||
Your exercise of the Licensed Rights is expressly made subject to the
|
|
||||||
following conditions.
|
|
||||||
|
|
||||||
a. Attribution.
|
|
||||||
|
|
||||||
1. If You Share the Licensed Material (including in modified
|
|
||||||
form), You must:
|
|
||||||
|
|
||||||
a. retain the following if it is supplied by the Licensor
|
|
||||||
with the Licensed Material:
|
|
||||||
|
|
||||||
i. identification of the creator(s) of the Licensed
|
|
||||||
Material and any others designated to receive
|
|
||||||
attribution, in any reasonable manner requested by
|
|
||||||
the Licensor (including by pseudonym if
|
|
||||||
designated);
|
|
||||||
|
|
||||||
ii. a copyright notice;
|
|
||||||
|
|
||||||
iii. a notice that refers to this Public License;
|
|
||||||
|
|
||||||
iv. a notice that refers to the disclaimer of
|
|
||||||
warranties;
|
|
||||||
|
|
||||||
v. a URI or hyperlink to the Licensed Material to the
|
|
||||||
extent reasonably practicable;
|
|
||||||
|
|
||||||
b. indicate if You modified the Licensed Material and
|
|
||||||
retain an indication of any previous modifications; and
|
|
||||||
|
|
||||||
c. indicate the Licensed Material is licensed under this
|
|
||||||
Public License, and include the text of, or the URI or
|
|
||||||
hyperlink to, this Public License.
|
|
||||||
|
|
||||||
2. You may satisfy the conditions in Section 3(a)(1) in any
|
|
||||||
reasonable manner based on the medium, means, and context in
|
|
||||||
which You Share the Licensed Material. For example, it may be
|
|
||||||
reasonable to satisfy the conditions by providing a URI or
|
|
||||||
hyperlink to a resource that includes the required
|
|
||||||
information.
|
|
||||||
|
|
||||||
3. If requested by the Licensor, You must remove any of the
|
|
||||||
information required by Section 3(a)(1)(A) to the extent
|
|
||||||
reasonably practicable.
|
|
||||||
|
|
||||||
b. ShareAlike.
|
|
||||||
|
|
||||||
In addition to the conditions in Section 3(a), if You Share
|
|
||||||
Adapted Material You produce, the following conditions also apply.
|
|
||||||
|
|
||||||
1. The Adapter's License You apply must be a Creative Commons
|
|
||||||
license with the same License Elements, this version or
|
|
||||||
later, or a BY-SA Compatible License.
|
|
||||||
|
|
||||||
2. You must include the text of, or the URI or hyperlink to, the
|
|
||||||
Adapter's License You apply. You may satisfy this condition
|
|
||||||
in any reasonable manner based on the medium, means, and
|
|
||||||
context in which You Share Adapted Material.
|
|
||||||
|
|
||||||
3. You may not offer or impose any additional or different terms
|
|
||||||
or conditions on, or apply any Effective Technological
|
|
||||||
Measures to, Adapted Material that restrict exercise of the
|
|
||||||
rights granted under the Adapter's License You apply.
|
|
||||||
|
|
||||||
|
|
||||||
Section 4 -- Sui Generis Database Rights.
|
|
||||||
|
|
||||||
Where the Licensed Rights include Sui Generis Database Rights that
|
|
||||||
apply to Your use of the Licensed Material:
|
|
||||||
|
|
||||||
a. for the avoidance of doubt, Section 2(a)(1) grants You the right
|
|
||||||
to extract, reuse, reproduce, and Share all or a substantial
|
|
||||||
portion of the contents of the database;
|
|
||||||
|
|
||||||
b. if You include all or a substantial portion of the database
|
|
||||||
contents in a database in which You have Sui Generis Database
|
|
||||||
Rights, then the database in which You have Sui Generis Database
|
|
||||||
Rights (but not its individual contents) is Adapted Material,
|
|
||||||
|
|
||||||
including for purposes of Section 3(b); and
|
|
||||||
c. You must comply with the conditions in Section 3(a) if You Share
|
|
||||||
all or a substantial portion of the contents of the database.
|
|
||||||
|
|
||||||
For the avoidance of doubt, this Section 4 supplements and does not
|
|
||||||
replace Your obligations under this Public License where the Licensed
|
|
||||||
Rights include other Copyright and Similar Rights.
|
|
||||||
|
|
||||||
|
|
||||||
Section 5 -- Disclaimer of Warranties and Limitation of Liability.
|
|
||||||
|
|
||||||
a. UNLESS OTHERWISE SEPARATELY UNDERTAKEN BY THE LICENSOR, TO THE
|
|
||||||
EXTENT POSSIBLE, THE LICENSOR OFFERS THE LICENSED MATERIAL AS-IS
|
|
||||||
AND AS-AVAILABLE, AND MAKES NO REPRESENTATIONS OR WARRANTIES OF
|
|
||||||
ANY KIND CONCERNING THE LICENSED MATERIAL, WHETHER EXPRESS,
|
|
||||||
IMPLIED, STATUTORY, OR OTHER. THIS INCLUDES, WITHOUT LIMITATION,
|
|
||||||
WARRANTIES OF TITLE, MERCHANTABILITY, FITNESS FOR A PARTICULAR
|
|
||||||
PURPOSE, NON-INFRINGEMENT, ABSENCE OF LATENT OR OTHER DEFECTS,
|
|
||||||
ACCURACY, OR THE PRESENCE OR ABSENCE OF ERRORS, WHETHER OR NOT
|
|
||||||
KNOWN OR DISCOVERABLE. WHERE DISCLAIMERS OF WARRANTIES ARE NOT
|
|
||||||
ALLOWED IN FULL OR IN PART, THIS DISCLAIMER MAY NOT APPLY TO YOU.
|
|
||||||
|
|
||||||
b. TO THE EXTENT POSSIBLE, IN NO EVENT WILL THE LICENSOR BE LIABLE
|
|
||||||
TO YOU ON ANY LEGAL THEORY (INCLUDING, WITHOUT LIMITATION,
|
|
||||||
NEGLIGENCE) OR OTHERWISE FOR ANY DIRECT, SPECIAL, INDIRECT,
|
|
||||||
INCIDENTAL, CONSEQUENTIAL, PUNITIVE, EXEMPLARY, OR OTHER LOSSES,
|
|
||||||
COSTS, EXPENSES, OR DAMAGES ARISING OUT OF THIS PUBLIC LICENSE OR
|
|
||||||
USE OF THE LICENSED MATERIAL, EVEN IF THE LICENSOR HAS BEEN
|
|
||||||
ADVISED OF THE POSSIBILITY OF SUCH LOSSES, COSTS, EXPENSES, OR
|
|
||||||
DAMAGES. WHERE A LIMITATION OF LIABILITY IS NOT ALLOWED IN FULL OR
|
|
||||||
IN PART, THIS LIMITATION MAY NOT APPLY TO YOU.
|
|
||||||
|
|
||||||
c. The disclaimer of warranties and limitation of liability provided
|
|
||||||
above shall be interpreted in a manner that, to the extent
|
|
||||||
possible, most closely approximates an absolute disclaimer and
|
|
||||||
waiver of all liability.
|
|
||||||
|
|
||||||
|
|
||||||
Section 6 -- Term and Termination.
|
|
||||||
|
|
||||||
a. This Public License applies for the term of the Copyright and
|
|
||||||
Similar Rights licensed here. However, if You fail to comply with
|
|
||||||
this Public License, then Your rights under this Public License
|
|
||||||
terminate automatically.
|
|
||||||
|
|
||||||
b. Where Your right to use the Licensed Material has terminated under
|
|
||||||
Section 6(a), it reinstates:
|
|
||||||
|
|
||||||
1. automatically as of the date the violation is cured, provided
|
|
||||||
it is cured within 30 days of Your discovery of the
|
|
||||||
violation; or
|
|
||||||
|
|
||||||
2. upon express reinstatement by the Licensor.
|
|
||||||
|
|
||||||
For the avoidance of doubt, this Section 6(b) does not affect any
|
|
||||||
right the Licensor may have to seek remedies for Your violations
|
|
||||||
of this Public License.
|
|
||||||
|
|
||||||
c. For the avoidance of doubt, the Licensor may also offer the
|
|
||||||
Licensed Material under separate terms or conditions or stop
|
|
||||||
distributing the Licensed Material at any time; however, doing so
|
|
||||||
will not terminate this Public License.
|
|
||||||
|
|
||||||
d. Sections 1, 5, 6, 7, and 8 survive termination of this Public
|
|
||||||
License.
|
|
||||||
|
|
||||||
|
|
||||||
Section 7 -- Other Terms and Conditions.
|
|
||||||
|
|
||||||
a. The Licensor shall not be bound by any additional or different
|
|
||||||
terms or conditions communicated by You unless expressly agreed.
|
|
||||||
|
|
||||||
b. Any arrangements, understandings, or agreements regarding the
|
|
||||||
Licensed Material not stated herein are separate from and
|
|
||||||
independent of the terms and conditions of this Public License.
|
|
||||||
|
|
||||||
|
|
||||||
Section 8 -- Interpretation.
|
|
||||||
|
|
||||||
a. For the avoidance of doubt, this Public License does not, and
|
|
||||||
shall not be interpreted to, reduce, limit, restrict, or impose
|
|
||||||
conditions on any use of the Licensed Material that could lawfully
|
|
||||||
be made without permission under this Public License.
|
|
||||||
|
|
||||||
b. To the extent possible, if any provision of this Public License is
|
|
||||||
deemed unenforceable, it shall be automatically reformed to the
|
|
||||||
minimum extent necessary to make it enforceable. If the provision
|
|
||||||
cannot be reformed, it shall be severed from this Public License
|
|
||||||
without affecting the enforceability of the remaining terms and
|
|
||||||
conditions.
|
|
||||||
|
|
||||||
c. No term or condition of this Public License will be waived and no
|
|
||||||
failure to comply consented to unless expressly agreed to by the
|
|
||||||
Licensor.
|
|
||||||
|
|
||||||
d. Nothing in this Public License constitutes or may be interpreted
|
|
||||||
as a limitation upon, or waiver of, any privileges and immunities
|
|
||||||
that apply to the Licensor or You, including from the legal
|
|
||||||
processes of any jurisdiction or authority.
|
|
||||||
|
|
||||||
|
|
||||||
=======================================================================
|
|
||||||
|
|
||||||
Creative Commons is not a party to its public
|
|
||||||
licenses. Notwithstanding, Creative Commons may elect to apply one of
|
|
||||||
its public licenses to material it publishes and in those instances
|
|
||||||
will be considered the “Licensor.” The text of the Creative Commons
|
|
||||||
public licenses is dedicated to the public domain under the CC0 Public
|
|
||||||
Domain Dedication. Except for the limited purpose of indicating that
|
|
||||||
material is shared under a Creative Commons public license or as
|
|
||||||
otherwise permitted by the Creative Commons policies published at
|
|
||||||
creativecommons.org/policies, Creative Commons does not authorize the
|
|
||||||
use of the trademark "Creative Commons" or any other trademark or logo
|
|
||||||
of Creative Commons without its prior written consent including,
|
|
||||||
without limitation, in connection with any unauthorized modifications
|
|
||||||
to any of its public licenses or any other arrangements,
|
|
||||||
understandings, or agreements concerning use of licensed material. For
|
|
||||||
the avoidance of doubt, this paragraph does not form part of the
|
|
||||||
public licenses.
|
|
||||||
|
|
||||||
Creative Commons may be contacted at creativecommons.org.
|
|
130
PLUGINS.md
130
PLUGINS.md
@ -1,50 +1,50 @@
|
|||||||
## 插件列表
|
## 插件列表
|
||||||
|
|
||||||
<!-- vim-markdown-toc GFM -->
|
#### [Colorschemes](#colorschemes-1)
|
||||||
|
|
||||||
- [颜色主题](#颜色主题)
|
#### [By topic](#by-topic-1)
|
||||||
- [按功能分类](#按功能分类)
|
|
||||||
- [文本对齐](#文本对齐)
|
|
||||||
- [语法检查](#语法检查)
|
|
||||||
- [代码补全](#代码补全)
|
|
||||||
- [Cycle](#cycle)
|
|
||||||
- [代码注释](#代码注释)
|
|
||||||
- [自动补全括号](#自动补全括号)
|
|
||||||
- [模糊搜索](#模糊搜索)
|
|
||||||
- [文本搜索](#文本搜索)
|
|
||||||
- [代码对齐线](#代码对齐线)
|
|
||||||
- [Navigation](#navigation)
|
|
||||||
- [插件管理](#插件管理)
|
|
||||||
- [代码片段](#代码片段)
|
|
||||||
- [状态栏](#状态栏)
|
|
||||||
- [Surround](#surround)
|
|
||||||
- [Taking notes](#taking-notes)
|
|
||||||
- [Testing](#testing)
|
|
||||||
- [文本对象](#文本对象)
|
|
||||||
- [Tmux](#tmux)
|
|
||||||
- [编辑历史管理](#编辑历史管理)
|
|
||||||
- [版本控制](#版本控制)
|
|
||||||
- [Writing](#writing)
|
|
||||||
- [Misc](#misc)
|
|
||||||
- [编程语言](#编程语言)
|
|
||||||
- [C、C++](#cc)
|
|
||||||
- [Clojure](#clojure)
|
|
||||||
- [Elixir](#elixir)
|
|
||||||
- [Go](#go)
|
|
||||||
- [HTML](#html)
|
|
||||||
- [Java](#java)
|
|
||||||
- [Javascript](#javascript)
|
|
||||||
- [Lua](#lua)
|
|
||||||
- [PHP](#php)
|
|
||||||
- [Python](#python)
|
|
||||||
- [TeX](#tex)
|
|
||||||
- [VimL](#viml)
|
|
||||||
|
|
||||||
<!-- vim-markdown-toc -->
|
- [Alignment](#alignment)
|
||||||
|
- [Building and linting](#building-and-linting)
|
||||||
|
- [Code completion](#code-completion)
|
||||||
|
- [Commenters](#commenters)
|
||||||
|
- [Cycle](#cycle)
|
||||||
|
- [Delimiter](#delimiter)
|
||||||
|
- [Fuzzy finders](#fuzzy-finders)
|
||||||
|
- [Grep tools](#grep-tools)
|
||||||
|
- [Indent](#indent)
|
||||||
|
- [Misc](#misc)
|
||||||
|
- [Navigation](#navigation)
|
||||||
|
- [Plugin managers](#plugin-managers)
|
||||||
|
- [Snippets](#snippets)
|
||||||
|
- [Statusline](#statusline)
|
||||||
|
- [Surround](#surround)
|
||||||
|
- [Taking notes](#taking-notes)
|
||||||
|
- [Testing](#testing)
|
||||||
|
- [Text objects](#text-objects)
|
||||||
|
- [Tmux](#tmux)
|
||||||
|
- [Undo history](#undo-history)
|
||||||
|
- [Version control](#version-control)
|
||||||
|
- [Writing](#writing)
|
||||||
|
|
||||||
### 颜色主题
|
#### [By filetype](#by-filetype-1)
|
||||||
|
|
||||||
以下为一些比较流行的颜色主题:
|
- [C and C++](#c-and-c)
|
||||||
|
- [Clojure](#clojure)
|
||||||
|
- [Elixir](#elixir)
|
||||||
|
- [Go](#go)
|
||||||
|
- [HTML](#html)
|
||||||
|
- [Java](#java)
|
||||||
|
- [Javascript](#javascript)
|
||||||
|
- [Lua](#lua)
|
||||||
|
- [PHP](#php)
|
||||||
|
- [Python](#python)
|
||||||
|
- [TeX](#tex)
|
||||||
|
- [VimL](#viml)
|
||||||
|
|
||||||
|
## Colorschemes
|
||||||
|
|
||||||
|
Here's a list of commonly used colorschemes:
|
||||||
|
|
||||||
- [acme-colors](https://github.com/plan9-for-vimspace/acme-colors)
|
- [acme-colors](https://github.com/plan9-for-vimspace/acme-colors)
|
||||||
- [apprentice](https://github.com/romainl/Apprentice)
|
- [apprentice](https://github.com/romainl/Apprentice)
|
||||||
@ -69,70 +69,65 @@
|
|||||||
Alternatively, generate your own colorscheme using [themer](https://github.com/mjswensen/themer)
|
Alternatively, generate your own colorscheme using [themer](https://github.com/mjswensen/themer)
|
||||||
or [Colortemplate](https://github.com/lifepillar/vim-colortemplate).
|
or [Colortemplate](https://github.com/lifepillar/vim-colortemplate).
|
||||||
|
|
||||||
### 按功能分类
|
## By topic
|
||||||
|
|
||||||
#### 文本对齐
|
#### Alignment
|
||||||
|
|
||||||
- [tabular](https://github.com/godlygeek/tabular)
|
- [tabular](https://github.com/godlygeek/tabular)
|
||||||
- [vim-easy-align](https://github.com/junegunn/vim-easy-align)
|
- [vim-easy-align](https://github.com/junegunn/vim-easy-align)
|
||||||
- [vim-lion](https://github.com/tommcdo/vim-lion)
|
- [vim-lion](https://github.com/tommcdo/vim-lion)
|
||||||
|
|
||||||
#### 语法检查
|
#### Building and linting
|
||||||
|
|
||||||
- [ale](https://github.com/w0rp/ale)
|
- [ale](https://github.com/w0rp/ale)
|
||||||
- [neomake](https://github.com/neomake/neomake)
|
- [neomake](https://github.com/neomake/neomake)
|
||||||
- [syntastic](https://github.com/vim-syntastic/syntastic)
|
- [syntastic](https://github.com/vim-syntastic/syntastic)
|
||||||
|
|
||||||
#### 代码补全
|
#### Code completion
|
||||||
|
|
||||||
- [VimCompletesMe](https://github.com/ajh17/VimCompletesMe)
|
|
||||||
- [YouCompleteMe](https://github.com/Valloric/YouCompleteMe)
|
|
||||||
- [asyncomplete.vim](https://github.com/prabirshrestha/asyncomplete.vim)
|
- [asyncomplete.vim](https://github.com/prabirshrestha/asyncomplete.vim)
|
||||||
- [completion-nvim](https://github.com/nvim-lua/completion-nvim)
|
|
||||||
- [completor.vim](https://github.com/maralla/completor.vim)
|
- [completor.vim](https://github.com/maralla/completor.vim)
|
||||||
- [deoplete.nvim](https://github.com/Shougo/deoplete.nvim)
|
- [deoplete.nvim](https://github.com/Shougo/deoplete.nvim)
|
||||||
- [neocomplete.vim](https://github.com/Shougo/neocomplete.vim)
|
- [neocomplete.vim](https://github.com/Shougo/neocomplete.vim)
|
||||||
- [nvim-compe](https://github.com/hrsh7th/nvim-compe)
|
|
||||||
- [nvim-completion-manager](https://github.com/roxma/nvim-completion-manager)
|
- [nvim-completion-manager](https://github.com/roxma/nvim-completion-manager)
|
||||||
- [supertab](https://github.com/ervandew/supertab)
|
- [supertab](https://github.com/ervandew/supertab)
|
||||||
- [vim-mucomplete](https://github.com/lifepillar/vim-mucomplete)
|
- [vim-mucomplete](https://github.com/lifepillar/vim-mucomplete)
|
||||||
|
- [VimCompletesMe](https://github.com/ajh17/VimCompletesMe)
|
||||||
|
- [YouCompleteMe](https://github.com/Valloric/YouCompleteMe)
|
||||||
|
|
||||||
#### Cycle
|
#### Cycle
|
||||||
|
|
||||||
- [switch.vim](https://github.com/AndrewRadev/switch.vim)
|
- [switch.vim](https://github.com/AndrewRadev/switch.vim)
|
||||||
- [vim-speeddating](https://github.com/tpope/vim-speeddating)
|
- [vim-speeddating](https://github.com/tpope/vim-speeddating)
|
||||||
|
|
||||||
#### 代码注释
|
#### Commenters
|
||||||
|
|
||||||
- [nerdcommenter](https://github.com/scrooloose/nerdcommenter)
|
- [nerdcommenter](https://github.com/scrooloose/nerdcommenter)
|
||||||
- [tcomment_vim](https://github.com/tomtom/tcomment_vim)
|
- [tcomment_vim](https://github.com/tomtom/tcomment_vim)
|
||||||
- [vim-commentary](https://github.com/tpope/vim-commentary)
|
- [vim-commentary](https://github.com/tpope/vim-commentary)
|
||||||
|
|
||||||
#### 自动补全括号
|
#### Delimiter
|
||||||
|
|
||||||
- [auto-pairs](https://github.com/jiangmiao/auto-pairs)
|
- [auto-pairs](https://github.com/jiangmiao/auto-pairs)
|
||||||
- [delimitMate](https://github.com/Raimondi/delimitMate)
|
- [delimitMate](https://github.com/Raimondi/delimitMate)
|
||||||
- [vim-endwise](https://github.com/tpope/vim-endwise)
|
- [vim-endwise](https://github.com/tpope/vim-endwise)
|
||||||
|
|
||||||
#### 模糊搜索
|
#### Fuzzy finders
|
||||||
|
|
||||||
- [leaderf](https://github.com/Yggdroot/LeaderF) (_requires +python3 or +python_)
|
|
||||||
- [denite.nvim](https://github.com/Shougo/denite.nvim) (_requires +python3_)
|
|
||||||
- [vim-clap](https://github.com/liuchengxu/vim-clap/)
|
|
||||||
- [Command-T](https://github.com/wincent/Command-T) (_requires +ruby_)
|
- [Command-T](https://github.com/wincent/Command-T) (_requires +ruby_)
|
||||||
- [ctrlp.vim](https://github.com/ctrlpvim/ctrlp.vim)
|
- [ctrlp.vim](https://github.com/ctrlpvim/ctrlp.vim)
|
||||||
|
- [denite.nvim](https://github.com/Shougo/denite.nvim) (_requires +python3_)
|
||||||
- [fzf](https://github.com/junegunn/fzf) (and [fzf.vim](https://github.com/junegunn/fzf.vim))
|
- [fzf](https://github.com/junegunn/fzf) (and [fzf.vim](https://github.com/junegunn/fzf.vim))
|
||||||
- [unite.vim](https://github.com/Shougo/unite.vim)
|
- [unite.vim](https://github.com/Shougo/unite.vim)
|
||||||
- [vim-fz](https://github.com/mattn/vim-fz)
|
- [vim-fz](https://github.com/mattn/vim-fz)
|
||||||
|
|
||||||
#### 文本搜索
|
#### Grep tools
|
||||||
|
|
||||||
- [ctrlsf.vim](https://github.com/dyng/ctrlsf.vim)
|
- [ctrlsf.vim](https://github.com/dyng/ctrlsf.vim)
|
||||||
- [ferret](https://github.com/wincent/ferret)
|
- [ferret](https://github.com/wincent/ferret)
|
||||||
- [vim-grepper](https://github.com/mhinz/vim-grepper)
|
- [vim-grepper](https://github.com/mhinz/vim-grepper)
|
||||||
- [flygrep](https://github.com/wsdjeg/FlyGrep.vim)
|
|
||||||
|
|
||||||
#### 代码对齐线
|
#### Indent
|
||||||
|
|
||||||
- [indentLine](https://github.com/Yggdroot/indentLine)
|
- [indentLine](https://github.com/Yggdroot/indentLine)
|
||||||
- [vim-indent-guides](https://github.com/nathanaelkane/vim-indent-guides)
|
- [vim-indent-guides](https://github.com/nathanaelkane/vim-indent-guides)
|
||||||
@ -146,11 +141,10 @@ or [Colortemplate](https://github.com/lifepillar/vim-colortemplate).
|
|||||||
- [vim-sneak](https://github.com/justinmk/vim-sneak)
|
- [vim-sneak](https://github.com/justinmk/vim-sneak)
|
||||||
- [vim-vinegar](https://github.com/tpope/vim-vinegar)
|
- [vim-vinegar](https://github.com/tpope/vim-vinegar)
|
||||||
- [vimfiler.vim](https://github.com/Shougo/vimfiler.vim) (_depends on other plugins_)
|
- [vimfiler.vim](https://github.com/Shougo/vimfiler.vim) (_depends on other plugins_)
|
||||||
- [defx.nvim](https://github.com/Shougo/defx.nvim) (_requires +python3_)
|
|
||||||
|
|
||||||
Also see [fuzzy finders](#fuzzy-finders).
|
Also see [fuzzy finders](#fuzzy-finders).
|
||||||
|
|
||||||
#### 插件管理
|
#### Plugin managers
|
||||||
|
|
||||||
- [apt-vim](https://github.com/egalpin/apt-vim)
|
- [apt-vim](https://github.com/egalpin/apt-vim)
|
||||||
- [dein.vim](https://github.com/Shougo/dein.vim)
|
- [dein.vim](https://github.com/Shougo/dein.vim)
|
||||||
@ -160,14 +154,14 @@ Also see [fuzzy finders](#fuzzy-finders).
|
|||||||
- [vim-plug](https://github.com/junegunn/vim-plug)
|
- [vim-plug](https://github.com/junegunn/vim-plug)
|
||||||
- [vundle.vim](https://github.com/VundleVim/Vundle.vim)
|
- [vundle.vim](https://github.com/VundleVim/Vundle.vim)
|
||||||
|
|
||||||
#### 代码片段
|
#### Snippets
|
||||||
|
|
||||||
- [neosnippet.vim](https://github.com/Shougo/neosnippet.vim) (_depends on other plugins_)
|
- [neosnippet.vim](https://github.com/Shougo/neosnippet.vim) (_depends on other plugins_)
|
||||||
- [ultisnips](https://github.com/SirVer/ultisnips)
|
- [ultisnips](https://github.com/SirVer/ultisnips)
|
||||||
- [vim-snipmate](https://github.com/garbas/vim-snipmate) (_depends on other plugins_)
|
- [vim-snipmate](https://github.com/garbas/vim-snipmate) (_depends on other plugins_)
|
||||||
- [xptemplate](https://github.com/drmingdrmer/xptemplate)
|
- [xptemplate](https://github.com/drmingdrmer/xptemplate)
|
||||||
|
|
||||||
#### 状态栏
|
#### Statusline
|
||||||
|
|
||||||
- [lightline.vim](https://github.com/itchyny/lightline.vim)
|
- [lightline.vim](https://github.com/itchyny/lightline.vim)
|
||||||
- [powerline](https://github.com/powerline/powerline)
|
- [powerline](https://github.com/powerline/powerline)
|
||||||
@ -193,7 +187,7 @@ Also see [fuzzy finders](#fuzzy-finders).
|
|||||||
|
|
||||||
- [vim-test](https://github.com/janko-m/vim-test)
|
- [vim-test](https://github.com/janko-m/vim-test)
|
||||||
|
|
||||||
#### 文本对象
|
#### Text objects
|
||||||
|
|
||||||
- [targets.vim](https://github.com/wellle/targets.vim)
|
- [targets.vim](https://github.com/wellle/targets.vim)
|
||||||
- [vim-exchange](https://github.com/tommcdo/vim-exchange)
|
- [vim-exchange](https://github.com/tommcdo/vim-exchange)
|
||||||
@ -208,13 +202,12 @@ Also see [fuzzy finders](#fuzzy-finders).
|
|||||||
- [vim-tmux-navigator](https://github.com/christoomey/vim-tmux-navigator)
|
- [vim-tmux-navigator](https://github.com/christoomey/vim-tmux-navigator)
|
||||||
- [vitality.vim](https://github.com/sjl/vitality.vim)
|
- [vitality.vim](https://github.com/sjl/vitality.vim)
|
||||||
|
|
||||||
#### 编辑历史管理
|
#### Undo history
|
||||||
|
|
||||||
- [vim-mundo](https://github.com/simnalamburt/vim-mundo)
|
|
||||||
- [gundo.vim](https://github.com/sjl/gundo.vim)
|
- [gundo.vim](https://github.com/sjl/gundo.vim)
|
||||||
- [undotree](https://github.com/mbbill/undotree)
|
- [undotree](https://github.com/mbbill/undotree)
|
||||||
|
|
||||||
#### 版本控制
|
#### Version control
|
||||||
|
|
||||||
- [agit.vim](https://github.com/cohama/agit.vim)
|
- [agit.vim](https://github.com/cohama/agit.vim)
|
||||||
- [committia.vim](https://github.com/rhysd/committia.vim)
|
- [committia.vim](https://github.com/rhysd/committia.vim)
|
||||||
@ -230,7 +223,6 @@ Also see [fuzzy finders](#fuzzy-finders).
|
|||||||
- [vim-lawrencium](https://bitbucket.org/ludovicchabant/vim-lawrencium)
|
- [vim-lawrencium](https://bitbucket.org/ludovicchabant/vim-lawrencium)
|
||||||
- [vim-signify](https://github.com/mhinz/vim-signify)
|
- [vim-signify](https://github.com/mhinz/vim-signify)
|
||||||
- [vimagit](https://github.com/jreybert/vimagit)
|
- [vimagit](https://github.com/jreybert/vimagit)
|
||||||
- [git-messenger.vim](https://github.com/rhysd/git-messenger.vim/)
|
|
||||||
|
|
||||||
#### Writing
|
#### Writing
|
||||||
|
|
||||||
@ -266,9 +258,9 @@ Also see [fuzzy finders](#fuzzy-finders).
|
|||||||
- [vim-startify](https://github.com/mhinz/vim-startify)
|
- [vim-startify](https://github.com/mhinz/vim-startify)
|
||||||
- [vim-unimpaired](https://github.com/tpope/vim-unimpaired)
|
- [vim-unimpaired](https://github.com/tpope/vim-unimpaired)
|
||||||
|
|
||||||
### 编程语言
|
## By filetype
|
||||||
|
|
||||||
#### C、C++
|
#### C and C++
|
||||||
|
|
||||||
- [a.vim](https://github.com/vim-scripts/a.vim)
|
- [a.vim](https://github.com/vim-scripts/a.vim)
|
||||||
- [clang_complete](https://github.com/Rip-Rip/clang_complete)
|
- [clang_complete](https://github.com/Rip-Rip/clang_complete)
|
||||||
|
413
README.md
413
README.md
@ -1,17 +1,15 @@
|
|||||||
<div align='center'>
|
# Vim 从入门到精通
|
||||||
<h1>Vim 从入门到精通</h1>
|
|
||||||
<div>
|
[](https://gitter.im/vim-china/Lobby)
|
||||||
<a href='https://github.com/mhinz/vim-galore'>English</a> |
|
[](https://t.me/VimHub)
|
||||||
<a href='http://postd.cc/?s=vim-galore'>Japanese</a> |
|
|
||||||
<a href='https://github.com/lsrdg/vim-galore'>Portuguese</a> |
|
> 旨在翻译 vim-galore 的基础上做了更多的补充
|
||||||
<a href='http://givi.olnd.ru/vim-galore/vim-galore-ru.html'>Russian</a>
|
|
||||||
<div>
|
- 原文地址:<https://github.com/mhinz/vim-galore>
|
||||||
<br />
|
- 原文作者:Marco Hinz
|
||||||
<sub>Licensed under <a href='https://creativecommons.org/licenses/by-sa/4.0'>CC BY-SA 4.0<a/>.</sub>
|
- 本文地址:<https://github.com/wsdjeg/vim-galore-zh_cn>
|
||||||
</div>
|
|
||||||
</div>
|
**注:转载清保留以上信息**
|
||||||
<br /><br />
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- vim-markdown-toc GFM -->
|
<!-- vim-markdown-toc GFM -->
|
||||||
|
|
||||||
@ -20,8 +18,6 @@
|
|||||||
- [Vim 哲学](#vim-哲学)
|
- [Vim 哲学](#vim-哲学)
|
||||||
- [入门](#入门)
|
- [入门](#入门)
|
||||||
- [精简的 vimrc](#精简的-vimrc)
|
- [精简的 vimrc](#精简的-vimrc)
|
||||||
- [Windows 系统](#windows-系统)
|
|
||||||
- [Linux 或者 Mac OS](#linux-或者-mac-os)
|
|
||||||
- [我正在使用什么样的 Vim](#我正在使用什么样的-vim)
|
- [我正在使用什么样的 Vim](#我正在使用什么样的-vim)
|
||||||
- [备忘录](#备忘录)
|
- [备忘录](#备忘录)
|
||||||
- [基础](#基础)
|
- [基础](#基础)
|
||||||
@ -74,22 +70,17 @@
|
|||||||
- [在 Vim 7 或者更早的版本中安装](#在-vim-7-或者更早的版本中安装)
|
- [在 Vim 7 或者更早的版本中安装](#在-vim-7-或者更早的版本中安装)
|
||||||
- [简短的介绍](#简短的介绍)
|
- [简短的介绍](#简短的介绍)
|
||||||
- [技巧](#技巧)
|
- [技巧](#技巧)
|
||||||
- [跳至选择的区域另一端](#跳至选择的区域另一端)
|
|
||||||
- [聪明地使用 n 和 N](#聪明地使用-n-和-n)
|
- [聪明地使用 n 和 N](#聪明地使用-n-和-n)
|
||||||
- [聪明地使用命令行历史](#聪明地使用命令行历史)
|
- [聪明地使用命令行历史](#聪明地使用命令行历史)
|
||||||
- [智能 Ctrl-l](#智能-ctrl-l)
|
- [智能 Ctrl-l](#智能-ctrl-l)
|
||||||
- [禁用错误报警声音和图标](#禁用错误报警声音和图标)
|
- [禁用错误报警声音和图标](#禁用错误报警声音和图标)
|
||||||
- [快速移动当前行](#快速移动当前行)
|
- [快速移动当前行](#快速移动当前行)
|
||||||
- [快速添加空行](#快速添加空行)
|
- [快速添加空行](#快速添加空行)
|
||||||
- [运行时检测](#运行时检测)
|
|
||||||
- [查看启动时间](#查看启动时间)
|
|
||||||
- [NUL 符用新行表示](#nul-符用新行表示)
|
|
||||||
- [快速编辑自定义宏](#快速编辑自定义宏)
|
- [快速编辑自定义宏](#快速编辑自定义宏)
|
||||||
- [快速跳转到源(头)文件](#快速跳转到源头文件)
|
- [快速跳转到源(头)文件](#快速跳转到源头文件)
|
||||||
- [在 GUI 中快速改变字体大小](#在-gui-中快速改变字体大小)
|
- [在 GUI 中快速改变字体大小](#在-gui-中快速改变字体大小)
|
||||||
- [根据模式改变光标类型](#根据模式改变光标类型)
|
- [根据模式改变光标类型](#根据模式改变光标类型)
|
||||||
- [防止水平滑动的时候失去选择](#防止水平滑动的时候失去选择)
|
- [防止水平滑动的时候失去选择](#防止水平滑动的时候失去选择)
|
||||||
- [选择当前行至结尾,排除换行符](#选择当前行至结尾排除换行符)
|
|
||||||
- [重新载入保存文件](#重新载入保存文件)
|
- [重新载入保存文件](#重新载入保存文件)
|
||||||
- [更加智能的当前行高亮](#更加智能的当前行高亮)
|
- [更加智能的当前行高亮](#更加智能的当前行高亮)
|
||||||
- [更快的关键字补全](#更快的关键字补全)
|
- [更快的关键字补全](#更快的关键字补全)
|
||||||
@ -103,20 +94,24 @@
|
|||||||
- [调整日志等级](#调整日志等级)
|
- [调整日志等级](#调整日志等级)
|
||||||
- [查看启动日志](#查看启动日志)
|
- [查看启动日志](#查看启动日志)
|
||||||
- [查看运行时日志](#查看运行时日志)
|
- [查看运行时日志](#查看运行时日志)
|
||||||
- [Vim 脚本调试](#vim-脚本调试)
|
- [Vim脚本调试](#vim脚本调试)
|
||||||
- [语法文件调试](#语法文件调试)
|
- [语法文件调试](#语法文件调试)
|
||||||
- [杂项](#杂项)
|
- [杂项](#杂项)
|
||||||
- [附加资源](#附加资源)
|
- [附加资源](#附加资源)
|
||||||
- [Vim 配置集合](#vim-配置集合)
|
- [Vim 配置集合](#vim-配置集合)
|
||||||
|
- [内置插件](#内置插件)
|
||||||
|
- [将 Control 映射到 CapsLock](#将-control-映射到-capslock)
|
||||||
|
- [复活节彩蛋](#复活节彩蛋)
|
||||||
|
- [为何使用 hjkl](#为何使用-hjkl)
|
||||||
- [常见问题](#常见问题)
|
- [常见问题](#常见问题)
|
||||||
- [编辑小文件时很慢](#编辑小文件时很慢)
|
- [编辑小文件时很慢](#编辑小文件时很慢)
|
||||||
- [编辑大文件的时候很慢](#编辑大文件的时候很慢)
|
- [编辑大文件的时候很慢](#编辑大文件的时候很慢)
|
||||||
- [持续粘贴(为什么我每次都要设置 'paste' 模式)](#持续粘贴为什么我每次都要设置-paste-模式)
|
- [持续粘贴(为什么我每次都要设置 'paste' 模式)](#持续粘贴为什么我每次都要设置-paste-模式)
|
||||||
- [在终端中按 ESC 后有延时](#在终端中按-esc-后有延时)
|
- [在终端中按 ESC 后有延时](#在终端中按-esc-后有延时)
|
||||||
- [无法重复函数中执行的搜索](#无法重复函数中执行的搜索)
|
- [无法重复函数中执行的搜索](#无法重复函数中执行的搜索)
|
||||||
- [进阶阅读](#进阶阅读)
|
- [插件列表](#插件列表)
|
||||||
- [加入我们](#加入我们)
|
- [加入我们](#加入我们)
|
||||||
- [参考资料](#参考资料)
|
- [致谢:](#致谢)
|
||||||
|
|
||||||
<!-- vim-markdown-toc -->
|
<!-- vim-markdown-toc -->
|
||||||
|
|
||||||
@ -124,50 +119,43 @@
|
|||||||
|
|
||||||
## 什么是 Vim?
|
## 什么是 Vim?
|
||||||
|
|
||||||
[Vim](https://github.com/vim/vim) 是一个历史悠久的文本编辑器,可以追溯到
|
[Vim](https://github.com/vim/vim) 是一个历史悠久的文本编辑器,可以追溯到 [qed](https://en.wikipedia.org/wiki/QED_(text_editor))。[Bram
|
||||||
[qed](<https://en.wikipedia.org/wiki/QED_(text_editor)>)。
|
Moolenaar](https://en.wikipedia.org/wiki/Bram_Moolenaar) 于 1991 年发布初始版本。
|
||||||
[Bram Moolenaar](https://en.wikipedia.org/wiki/Bram_Moolenaar) 于
|
|
||||||
1991 年发布初始版本。
|
|
||||||
|
|
||||||
Linux、Mac 用户,可以使用包管理器安装 Vim,对于 Windows 用户,可以从
|
Linux、Mac 用户,可以使用包管理器安装 Vim,对于 Windows 用户,可以从 [我的网盘](https://share.weiyun.com/da2be5937ac0e2bd3abc26355fad1204) 下载。
|
||||||
[我的网盘](https://www.jianguoyun.com/p/DVBqom8QtY2QCBj7xL0EIAA) 下载。
|
该版本可轻易添加 `python` 、`python3` 、`lua` 等支持,只需要安装 python、lua 即可。
|
||||||
该版本可轻易添加 `python` 、`python3` 、`lua` 等支持,只需要安装 python、lua
|
|
||||||
即可。
|
中文讨论使用相关问题最好使用 [vim_cn](https://groups.google.com/forum/#!forum/vim-cn) 邮件列表或者使用
|
||||||
|
IRC([Freenode](https://freenode.net)) 的 `#vim-china` 频道。同时可以关注 Github 上的 vim-china 中文社区:
|
||||||
|
https://github.com/vim-china/vim-china.github.io
|
||||||
|
|
||||||
项目在 [Github](https://github.com/vim/vim) 上开发,项目讨论请订阅
|
项目在 [Github](https://github.com/vim/vim) 上开发,项目讨论请订阅
|
||||||
[`vim_dev`](https://groups.google.com/forum/#!forum/vim_dev) 邮件列表。
|
[vim_dev](https://groups.google.com/forum/#!forum/vim_dev) 邮件列表。
|
||||||
|
|
||||||
通过阅读 [Why, oh WHY, do those #?@! nutheads use vi?](http://www.viemu.com/a-why-vi-vim.html)
|
通过阅读 [Why, oh WHY, do those #?@! nutheads use vi?](http://www.viemu.com/a-why-vi-vim.html) 来对 Vim 进行大致的了解。
|
||||||
来对 Vim 进行大致的了解。
|
|
||||||
|
返回主目录 [:arrow_heading_up:](#简介)
|
||||||
|
|
||||||
## Vim 哲学
|
## Vim 哲学
|
||||||
|
|
||||||
Vim 采用模式编辑的理念,即它提供了多种模式,按键在不同的模式下作用不同。
|
Vim 采用模式编辑的理念,即它提供了多种模式,按键在不同的模式下作用不同。你可以在 _普通模式_ 下浏览文件,在 _插入模式_ 下插入文本,在 _可视模式_ 下选择行,在 _命令模式_ 下执行命令等等。起初这听起来可能很复杂,但是这有一个很大的优点:不需要通过同时按住多个键来完成操作,大多数时候你只需要依次按下这些按键即可。越常用的操作,所需要的按键数量越少。
|
||||||
你可以在**普通模式** 下浏览文件,在**插入模式**下插入文本,
|
|
||||||
在**可视模式**下选择行,在**命令模式**下执行命令等等。起初这听起来可能很复杂,
|
|
||||||
但是这有一个很大的优点:不需要通过同时按住多个键来完成操作,
|
|
||||||
大多数时候你只需要依次按下这些按键即可。越常用的操作,所需要的按键数量越少。
|
|
||||||
|
|
||||||
和模式编辑紧密相连的概念是 **操作符** 和 **动作**。**操作符** 指的是开始某个行为,
|
和模式编辑紧密相连的概念是“操作符”和“动作”。_操作符_ 开始一些行为,例如:修改,删除,或者选择文本。之后你要用一个 _动作_ 来指定需要操作的文本区域。比如,要改变括号内的文本,需要执行 `ci(` (读做 _change inner parentheses_);删除整个段落的内容,需要执行 `dap` (读做:_delete
|
||||||
例如:修改、删除或者选择文本,之后你要用一个 **动作** 来指定需要操作的文本区域。
|
around paragraph_)。
|
||||||
比如,要改变括号内的文本,需要执行 `ci(` (读做 `change inner parentheses`);
|
|
||||||
删除整个段落的内容,需要执行 `dap` (读做:`delete around paragraph`)。
|
|
||||||
|
|
||||||
如果你能看见 Vim 老司机操作,你会发现他们使用 Vim 脚本语言就如同钢琴师弹钢琴一样。
|
如果你能看见 Vim 老司机操作,你会发现他们使用 Vim 脚本语言就如同钢琴师弹钢琴一样。复杂的操作只需要几个按键就能完成。他们甚至不用刻意去想,因为这已经成为[肌肉记忆](https://en.wikipedia.org/wiki/Muscle_memory)了。这减少[认识负荷](https://en.wikipedia.org/wiki/Cognitive_load)并帮助人们专注于实际任务。
|
||||||
复杂的操作只需要几个按键就能完成。他们甚至不用刻意去想,因为这已经成为[肌肉记忆](https://en.wikipedia.org/wiki/Muscle_memory)了。
|
|
||||||
这减少[认识负荷](https://en.wikipedia.org/wiki/Cognitive_load)并帮助人们专注于实际任务。
|
返回主目录 [:arrow_heading_up:](#简介)
|
||||||
|
|
||||||
## 入门
|
## 入门
|
||||||
|
|
||||||
Vim 自带一个交互式的教程,内含你需要了解的最基础的信息,你可以通过终端运行以下命令打开教程:
|
Vim 自带一个交互式的教程,内含你需要了解的最基础的信息,你可以通过终端运行以下命令打开教程:
|
||||||
|
|
||||||
```
|
$ vimtutor
|
||||||
$ vimtutor
|
|
||||||
```
|
|
||||||
|
|
||||||
不要因为这个看上去很无聊而跳过,按照此教程多练习。你以前用的 IDE 或者其他编辑器很少是有“模式”概念的,因此一开始你会很难适应模式切换。但是你 Vim 使用的越多,[肌肉记忆](https://en.wikipedia.org/wiki/Muscle_memory) 将越容易形成。
|
不要因为这个看上去很无聊而跳过,按照此教程多练习。你以前用的 IDE 或者其他编辑器很少是有“模式”概念的,因此一开始你会很难适应模式切换。但是你 Vim 使用的越多,[肌肉记忆](https://en.wikipedia.org/wiki/Muscle_memory) 将越容易形成。
|
||||||
|
|
||||||
Vim 基于一个 [vi](https://en.wikipedia.org/wiki/Vi) 克隆,叫做 [Stevie](<https://en.wikipedia.org/wiki/Stevie_(text_editor)>),支持两种运行模式:"compatible" 和 "nocompatible"。在兼容模式下运行 Vim 意味着使用 vi 的默认设置,而不是 Vim 的默认设置。除非你新建一个用户的 `vimrc` 或者使用 `vim -N` 命令启动 Vim,否则就是在兼容模式下运行 Vim!请大家不要在兼容模式下运行 Vim。
|
Vim 基于一个 [vi](https://en.wikipedia.org/wiki/Vi) 克隆,叫做 [Stevie](https://en.wikipedia.org/wiki/Stevie_(text_editor)),支持两种运行模式:"compatible" 和 "nocompatible"。在兼容模式下运行 Vim 意味着使用 vi 的默认设置,而不是 Vim 的默认设置。除非你新建一个用户的 `vimrc` 或者使用 `vim -N` 命令启动 Vim,否则就是在兼容模式下运行 Vim!请大家不要在兼容模式下运行 Vim。
|
||||||
|
|
||||||
下一步
|
下一步
|
||||||
|
|
||||||
@ -183,44 +171,7 @@ Vim 基于一个 [vi](https://en.wikipedia.org/wiki/Vi) 克隆,叫做 [Stevie]
|
|||||||
|
|
||||||
## 精简的 vimrc
|
## 精简的 vimrc
|
||||||
|
|
||||||
Vim 启动是会按照一定的优先顺序来搜索配置文件,这个顺序,可以通过 `:version` 命令查看。下面分 Windows 系统,
|
用户的 vimrc 配置文件可以放在 `~/.vimrc`,或者为了更好的分离放在 `~/.vim/vimrc`,后者更便于通过版本控制软件备份和同步整个配置,比方说 Github。
|
||||||
和 \*niux 系统分别来说明 Vim 是如何载入配置文件的。
|
|
||||||
|
|
||||||
### Windows 系统
|
|
||||||
|
|
||||||
```
|
|
||||||
system vimrc file: "$VIM\vimrc"
|
|
||||||
user vimrc file: "$HOME\_vimrc"
|
|
||||||
2nd user vimrc file: "$HOME\vimfiles\vimrc"
|
|
||||||
3rd user vimrc file: "$VIM\_vimrc"
|
|
||||||
user exrc file: "$HOME\_exrc"
|
|
||||||
2nd user exrc file: "$VIM\_exrc"
|
|
||||||
system gvimrc file: "$VIM\gvimrc"
|
|
||||||
user gvimrc file: "$HOME\_gvimrc"
|
|
||||||
2nd user gvimrc file: "$HOME\vimfiles\gvimrc"
|
|
||||||
3rd user gvimrc file: "$VIM\_gvimrc"
|
|
||||||
defaults file: "$VIMRUNTIME\defaults.vim"
|
|
||||||
system menu file: "$VIMRUNTIME\menu.vim"
|
|
||||||
```
|
|
||||||
|
|
||||||
我们只看上面这一段,Vim 会优先读取 user vimrc file: `$HOME\_vimrc`, 当这一文件不存在是,
|
|
||||||
Vim 再去寻找 2nd user vimrc file: `$HOME\vimfiles\vimrc`; 倘若这个文件还是不存在,那么 Vim
|
|
||||||
会去继续寻找 3rd user vimrc file: `$VIM\_vimrc`。 了解以上顺序后,就不会再因为 Vim
|
|
||||||
总是不读取配置文件而感到烦恼了。
|
|
||||||
|
|
||||||
### Linux 或者 Mac OS
|
|
||||||
|
|
||||||
同 Windows 系统类似,也可以使用 `:version` 命令查看 vim 载入配置的优先顺序。
|
|
||||||
|
|
||||||
```
|
|
||||||
系统 vimrc 文件: "/etc/vimrc"
|
|
||||||
用户 vimrc 文件: "$HOME/.vimrc"
|
|
||||||
第二用户 vimrc 文件: "~/.vim/vimrc"
|
|
||||||
用户 exrc 文件: "$HOME/.exrc"
|
|
||||||
defaults file: "$VIMRUNTIME/defaults.vim"
|
|
||||||
$VIM 预设值: "/etc"
|
|
||||||
$VIMRUNTIME 预设值: "/usr/share/vim/vim81"
|
|
||||||
```
|
|
||||||
|
|
||||||
你可以在网上找到许多精简的 vimrc 配置文件,我的版本可能并不是最简单的版本,但是我的版本提供了一套我认为良好的,非常适合入门的设置。
|
你可以在网上找到许多精简的 vimrc 配置文件,我的版本可能并不是最简单的版本,但是我的版本提供了一套我认为良好的,非常适合入门的设置。
|
||||||
|
|
||||||
@ -228,7 +179,7 @@ Vim 再去寻找 2nd user vimrc file: `$HOME\vimfiles\vimrc`; 倘若这个文件
|
|||||||
|
|
||||||
精简的 vimrc 地址:[minimal-vimrc](contents/minimal-vimrc.vim)
|
精简的 vimrc 地址:[minimal-vimrc](contents/minimal-vimrc.vim)
|
||||||
|
|
||||||
如果你有兴趣,这里是我(原作者)的 [vimrc](https://github.com/mhinz/dotfiles/blob/master/.vim/vimrc)。
|
如果你有兴趣,这里是我(原作者)的 [vimrc](https://github.com/mhinz/dotfiles/blob/master/vim/vimrc)。
|
||||||
|
|
||||||
**建议**:大多数插件作者都维护不止一个插件并且将他们的 vimrc 放在 Github 上展示(通常放在叫做 "vim-config" 或者 "dotfiles" 的仓库中),所以当你发现你喜欢的插件时,去插件维护者的 Github 主页看看有没有这样的仓库。
|
**建议**:大多数插件作者都维护不止一个插件并且将他们的 vimrc 放在 Github 上展示(通常放在叫做 "vim-config" 或者 "dotfiles" 的仓库中),所以当你发现你喜欢的插件时,去插件维护者的 Github 主页看看有没有这样的仓库。
|
||||||
|
|
||||||
@ -238,7 +189,7 @@ Vim 再去寻找 2nd user vimrc file: `$HOME\vimfiles\vimrc`; 倘若这个文件
|
|||||||
|
|
||||||
使用 `:version` 命令将向你展示当前正在运行的 Vim 的所有相关信息,包括它是如何编译的。
|
使用 `:version` 命令将向你展示当前正在运行的 Vim 的所有相关信息,包括它是如何编译的。
|
||||||
|
|
||||||
第一行告诉你这个二进制文件的编译时间和版本号,比如:7.4。接下来的一行呈现 `Included patches: 1-1051`,这是补丁版本包。因此你 Vim 确切的版本号是 7.4.1051。
|
第一行告诉你这个二进制文件的编译时间和版本号,比如:7.4。接下来的一行呈现 `Included patches: 1-1051`,这是补丁版本包。因此你 Vim 确切的版本号是 7.4.1051。
|
||||||
|
|
||||||
另一行显示着一些像 `Tiny version without GUI` 或者 `Huge version with GUI` 的信息。很显然这些信息告诉你当前的 Vim 是否支持 GUI,例如:从终端中运行 `gvim` 或者从终端模拟器中的 Vim 内运行 `:gui` 命令。另一个重要的信息是 `Tiny` 和 `Huge`。Vim 的特性集区分被叫做 `tiny`,`small`,`normal`,`big` and `huge`,所有的都实现不同的功能子集。
|
另一行显示着一些像 `Tiny version without GUI` 或者 `Huge version with GUI` 的信息。很显然这些信息告诉你当前的 Vim 是否支持 GUI,例如:从终端中运行 `gvim` 或者从终端模拟器中的 Vim 内运行 `:gui` 命令。另一个重要的信息是 `Tiny` 和 `Huge`。Vim 的特性集区分被叫做 `tiny`,`small`,`normal`,`big` and `huge`,所有的都实现不同的功能子集。
|
||||||
|
|
||||||
@ -259,12 +210,10 @@ endif
|
|||||||
|
|
||||||
相关帮助:
|
相关帮助:
|
||||||
|
|
||||||
```
|
:h :version
|
||||||
:h :version
|
:h feature-list
|
||||||
:h feature-list
|
:h +feature-list
|
||||||
:h +feature-list
|
:h has-patch
|
||||||
:h has-patch
|
|
||||||
```
|
|
||||||
|
|
||||||
返回主目录 [:arrow_heading_up:](#简介)
|
返回主目录 [:arrow_heading_up:](#简介)
|
||||||
|
|
||||||
@ -274,6 +223,7 @@ endif
|
|||||||
|
|
||||||
- <http://people.csail.mit.edu/vgod/vim/vim-cheat-sheet-en.png>
|
- <http://people.csail.mit.edu/vgod/vim/vim-cheat-sheet-en.png>
|
||||||
- <https://cdn.shopify.com/s/files/1/0165/4168/files/preview.png>
|
- <https://cdn.shopify.com/s/files/1/0165/4168/files/preview.png>
|
||||||
|
- <http://www.nathael.org/Data/vi-vim-cheat-sheet.svg>
|
||||||
- <http://michael.peopleofhonoronly.com/vim/vim_cheat_sheet_for_programmers_screen.png>
|
- <http://michael.peopleofhonoronly.com/vim/vim_cheat_sheet_for_programmers_screen.png>
|
||||||
- <http://www.rosipov.com/images/posts/vim-movement-commands-cheatsheet.png>
|
- <http://www.rosipov.com/images/posts/vim-movement-commands-cheatsheet.png>
|
||||||
|
|
||||||
@ -341,16 +291,16 @@ Vim 是一个文本编辑器。每次文本都是作为**缓冲区**的一部分
|
|||||||
|
|
||||||
## 按键映射
|
## 按键映射
|
||||||
|
|
||||||
使用 `:map` 命令家族你可以定义属于你自己的快捷键。该家族的每一个命令都限定在特定的模式下。从技术上来说 Vim 自带高达 12 种模式,其中 6 种可以被映射。另外一些命令作用于多种模式:
|
使用 `:map` 命令家族你可以定义属于你自己的快捷键。该家族的每一个命令都限定在特定的模式下。从技术上来说 Vim 自带高达 12 中模式,其中 6 种可以被映射。另外一些命令作用于多种模式:
|
||||||
|
|
||||||
| 递归 | 非递归 | 模式 |
|
| 递归 | 非递归 | 模式 |
|
||||||
| -------- | ------------ | -------------------------------- |
|
| --------- | ------------ | -------------------------------- |
|
||||||
| `:map` | `:noremap` | normal, visual, operator-pending |
|
| `:map` | `:noremap` | normal, visual, operator-pending |
|
||||||
| `:nmap` | `:nnoremap` | normal |
|
| `:nmap` | `:nnoremap` | normal |
|
||||||
| `:xmap` | `:xnoremap` | visual |
|
| `:xmap` | `:xnoremap` | visual |
|
||||||
| `:cmap` | `:cnoremap` | command-line |
|
| `:cmap` | `:cnoremap` | command-line |
|
||||||
| `:omap` | `:onoremap` | operator-pending |
|
| `:omap` | `:onoremap` | operator-pending |
|
||||||
| `:imap` | `:inoremap` | insert |
|
| `:imap` | `:inoremap` | insert |
|
||||||
|
|
||||||
例如:这个自定义的快捷键只在普通模式下工作。
|
例如:这个自定义的快捷键只在普通模式下工作。
|
||||||
|
|
||||||
@ -384,7 +334,7 @@ Vim 是一个文本编辑器。每次文本都是作为**缓冲区**的一部分
|
|||||||
:nnoremap a b
|
:nnoremap a b
|
||||||
```
|
```
|
||||||
|
|
||||||
经验法则:除递归映射是必须的,否则总是使用非递归映射。
|
经验法则:除非递归是必须的,否则总是使用非递归映射。
|
||||||
|
|
||||||
通过不给一个右值来检查你的映射。比如`:nmap` 显示所以普通模式下的映射,`:nmap <leader>` 显示所有以 `<leader>` 键开头的普通模式下的映射。
|
通过不给一个右值来检查你的映射。比如`:nmap` 显示所以普通模式下的映射,`:nmap <leader>` 显示所有以 `<leader>` 键开头的普通模式下的映射。
|
||||||
|
|
||||||
@ -408,15 +358,13 @@ Vim 是一个文本编辑器。每次文本都是作为**缓冲区**的一部分
|
|||||||
nnoremap <leader>h :helpgrep<space>
|
nnoremap <leader>h :helpgrep<space>
|
||||||
```
|
```
|
||||||
|
|
||||||
这样,我们只需要先按 <kbd>\\</kbd> 然后按 <kbd>h</kbd> 就可以激活这个映射 `:helpgrep<space>`。如果你想通过先按 <kbd>空格</kbd> 键来触发,只需要这样做:
|
这样,我们只需要先按 <kbd>\\</kbd> 然后连续按 <kbd>\\h</kbd> 就可以激活这个映射 `:helpgrep<space>`。如果你想通过先按 <kbd>空格</kbd> 键来触发,只需要这样做:
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
let g:mapleader = ' '
|
let mapleader = ' '
|
||||||
nnoremap <leader>h :helpgrep<space>
|
nnoremap <leader>h :helpgrep<space>
|
||||||
```
|
```
|
||||||
|
|
||||||
此处建议使用 `g:mapleader`,因为在 Vim 脚本中,函数外的变量缺省的作用域是全局变量,但是在函数内缺省作用域是局部变量,而设置快捷键前缀需要修改全局变量 `g:mapleader` 的值。
|
|
||||||
|
|
||||||
另外,还有一个叫 `<localleader>` 的,可以把它理解为局部环境中的 `<leader>`,默认值依然为 <kbd>\\</kbd>。当我们需要只对某一个条件下(比如,特定文件类型的插件)的缓冲区设置特别的 `<leader>` 键,那么我们就可以通过修改当前环境下的 `<localleader>` 来实现。
|
另外,还有一个叫 `<localleader>` 的,可以把它理解为局部环境中的 `<leader>`,默认值依然为 <kbd>\\</kbd>。当我们需要只对某一个条件下(比如,特定文件类型的插件)的缓冲区设置特别的 `<leader>` 键,那么我们就可以通过修改当前环境下的 `<localleader>` 来实现。
|
||||||
|
|
||||||
**注意**:如果你打算设置 Leader 键,请确保在设置按键映射之前,先设置好 Leader 键。如果你先设置了含有 Leader 键的映射,然后又修改了 Leader 键,那么之前映射内的 Leader 键是不会因此而改变的。你可以通过执行 `:nmap <leader>` 来查看普通模式中已绑定给 Leader 键的所有映射。
|
**注意**:如果你打算设置 Leader 键,请确保在设置按键映射之前,先设置好 Leader 键。如果你先设置了含有 Leader 键的映射,然后又修改了 Leader 键,那么之前映射内的 Leader 键是不会因此而改变的。你可以通过执行 `:nmap <leader>` 来查看普通模式中已绑定给 Leader 键的所有映射。
|
||||||
@ -431,19 +379,19 @@ nnoremap <leader>h :helpgrep<space>
|
|||||||
|
|
||||||
Vim 为我们提供了如下的寄存器:
|
Vim 为我们提供了如下的寄存器:
|
||||||
|
|
||||||
| 类型 | 标识 | 读写者 | 是否为只读 | 包含的字符来源 |
|
| 类型 | 标识 | 读写者 | 是否为只读 | 包含的字符来源 |
|
||||||
| ------------------- | ------------------ | ------ | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| ------------------- | ------------------ | ------ | ---------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| Unnamed | `"` | vim | 否 | 最近一次的复制或删除操作 (`d`, `c`, `s`, `x`, `y`) |
|
| Unnamed | `"` | vim | 否 | 最近一次的复制或删除操作 (`d`, `c`, `s`, `x`, `y`) |
|
||||||
| Numbered | `0`至`9` | vim | 否 | 寄存器 `0`: 最近一次复制。寄存器 `1`: 最近一次删除。寄存器 `2`: 倒数第二次删除,以此类推。对于寄存器 `1` 至 `9`,他们其实是只读的最多包含 9 个元素的队列。这里的队列即为数据类型 [queue](<https://en.wikipedia.org/wiki/Queue_(abstract_data_type)>) |
|
| Numbered | `0`至`9` | vim | 否 | 寄存器 `0`: 最近一次复制。寄存器 `1`: 最近一次删除。寄存器 `2`: 倒数第二次删除,以此类推。对于寄存器 `1` 至 `9`,他们其实是只读的最多包含 9 个元素的队列。这里的队列即为数据类型 [queue](https://en.wikipedia.org/wiki/Queue_(abstract_data_type)) |
|
||||||
| Small delete | `-` | vim | 否 | 最近一次行内删除 |
|
| Small delete | `-` | vim | 否 | 最近一次行内删除 |
|
||||||
| Named | `a`至`z`, `A`至`Z` | 用户 | 否 | 如果你通过复制操作存储文本至寄存器 `a`,那么 `a` 中的文本就会被完全覆盖。如果你存储至 `A`,那么会将文本添加给寄存器 `a`,不会覆盖之前已有的文本 |
|
| Named | `a`至`z`, `A`至`Z` | 用户 | 否 | 如果你通过复制操作存储文本至寄存器 `a`,那么 `a` 中的文本就会被完全覆盖。如果你存储至 `A`,那么会将文本添加给寄存器 `a`,不会覆盖之前已有的文本 |
|
||||||
| Read-only | `:`与`.`和`%` | vim | 是 | `:`: 最近一次使用的命令,`.`: 最近一次添加的文本,`%`: 当前的文件名 |
|
| Read-only | `:`与`.`和`%` | vim | 是 | `:`: 最近一次使用的命令,`.`: 最近一次添加的文本,`%`: 当前的文件名 |
|
||||||
| Alternate buffer | `#` | vim | 否 | 大部分情况下,这个寄存器是当前窗口中,上一次访问的缓冲区。请参阅 `:h alternate-file` 来获取更多帮助 |
|
| Alternate buffer | `#` | vim | 否 | 大部分情况下,这个寄存器是当前窗口中,上一次访问的缓冲区。请参阅 `:h alternate-file` 来获取更多帮助 |
|
||||||
| Expression | `=` | 用户 | 否 | 复制 VimL 代码时,这个寄存器用于存储代码片段的执行结果。比如,在插入模式下复制 `<c-r>=5+5<cr>`,那么这个寄存器就会存入 10 |
|
| Expression | `=` | 用户 | 否 | 复制 VimL 代码时,这个寄存器用于存储代码片段的执行结果。比如,在插入模式下复制 `<c-r>=5+5<cr>`,那么这个寄存器就会存入 10 |
|
||||||
| Selection | `+`和`*` | vim | 否 | `*` 和 `+` 是 [剪贴板](#剪贴板) 寄存器 |
|
| Selection | `+`和`*` | vim | 否 | `*` 和 `+` 是 [剪贴板](#剪贴板) 寄存器 |
|
||||||
| Drop | `~` | vim | 是 | 最后一次拖拽添加至 Vim 的文本(需要 "+dnd" 支持,暂时只支持 GTK GUI。请参阅 `:help dnd` 及 `:help quote~`) |
|
| Drop | `~` | vim | 是 | 最后一次拖拽添加至 Vim 的文本(需要 "+dnd" 支持,暂时只支持 GTK GUI。请参阅 `:help dnd` 及 `:help quote~`) |
|
||||||
| Black hole | `_` | vim | 否 | 一般称为黑洞寄存器。对于当前操作,如果你不希望在其他寄存器中保留文本,那就在命令前加上 `_`。比如,`"_dd` 命令不会将文本放到寄存器 `"`、`1`、`+` 或 `*` 中 |
|
| Black hole | `_` | vim | 否 | 一般称为黑洞寄存器。对于当前操作,如果你不希望在其他寄存器中保留文本,那就在命令前加上 `_`。比如,`"_dd` 命令不会将文本放到寄存器 `"`、`1`、`+` 或 `*` 中 |
|
||||||
| Last search pattern | `/` | vim | 否 | 最近一次通过 `/`、`?` 或 `:global` 等命令调用的匹配条件 |
|
| Last search pattern | `/` | vim | 否 | 最近一次通过 `/`、`?` 或 `:global` 等命令调用的匹配条件 |
|
||||||
|
|
||||||
只要不是只读的寄存器,用户都有权限修改它的内容,比如:
|
只要不是只读的寄存器,用户都有权限修改它的内容,比如:
|
||||||
|
|
||||||
@ -535,28 +483,28 @@ Vim 为我们提供了如下的寄存器:
|
|||||||
| `A`-`Z` | 用户 | 全局标注,可以作用于不同文件。大写标注也称为「文件标注」。跳转时有可能会切换到另一个缓冲区 |
|
| `A`-`Z` | 用户 | 全局标注,可以作用于不同文件。大写标注也称为「文件标注」。跳转时有可能会切换到另一个缓冲区 |
|
||||||
| `0`-`9` | viminfo | `0` 代表 viminfo 最后一次被写入的位置。实际使用中,就代表 Vim 进程最后一次结束的位置。`1` 代表 Vim 进程倒数第二次结束的位置,以此类推 |
|
| `0`-`9` | viminfo | `0` 代表 viminfo 最后一次被写入的位置。实际使用中,就代表 Vim 进程最后一次结束的位置。`1` 代表 Vim 进程倒数第二次结束的位置,以此类推 |
|
||||||
|
|
||||||
如果想跳转到指定的标注,你可以先按下 `'` / `g'` 或者 `` ` `` / `` g` `` 然后按下标注名。
|
如果想跳转到指定的标注,你可以先按下 `'` / `g'` 或者 `` ` `` / ``g` `` 然后按下标注名。
|
||||||
|
|
||||||
如果你想定义当前文件中的标注,可以先按下 `m` 再按下标注名。比如,按下 `mm` 就可以把当前位置标注为 `m`。在这之后,如果你的光标切换到了文件的其他位置,只需要通过 `'m` 或者 `` `m ``即可回到刚才标注的行。区别在于,`'m`会跳转回被标记行的第一个非空字符,而`` `m ``会跳转回被标记行的被标记列。根据 viminfo 的设置,你可以在退出 Vim 的时候保留小写字符标注。请参阅`:h viminfo-'` 来获取更多帮助。
|
如果你想定义当前文件中的标注,可以先按下 `m` 再按下标注名。比如,按下 `mm` 就可以把当前位置标注为 `m`。在这之后,如果你的光标切换到了文件的其他位置,只需要通过 `'m` 或者 `\`m`即可回到刚才标注的行。区别在于,`'m`会跳转回被标记行的第一个非空字符,而`\`m`会跳转回被标记行的被标记列。根据 viminfo 的设置,你可以在退出 Vim 的时候保留小写字符标注。请参阅`:h viminfo-'\` 来获取更多帮助。
|
||||||
|
|
||||||
如果你想定义全局的标注,可以先按下 `m` 再按下大写英文字符。比如,按下 `mM` 就可以把当前文件的当前位置标注为 `M`。在这之后,就算你切换到其他的缓冲区,依然可以通过 `'M` 或 `` `M `` 跳转回来。
|
如果你想定义全局的标注,可以先按下 `m` 再按下大写英文字符。比如,按下 `mM` 就可以把当前文件的当前位置标注为 `M`。在这之后,就算你切换到其他的缓冲区,依然可以通过 `'M` 或 `\`M\` 跳转回来。
|
||||||
|
|
||||||
关于跳转,还有以下的方式:
|
关于跳转,还有以下的方式:
|
||||||
|
|
||||||
| 按键 | 跳转至 |
|
| 按键 | 跳转至 |
|
||||||
| ---------------- | ---------------------------------------------- |
|
| --------------- | ---------------------------------------------- |
|
||||||
| `'[` 与 `` `[ `` | 上一次修改或复制的第一行或第一个字符 |
|
| `'[` 与 `` `[`` | 上一次修改或复制的第一行或第一个字符 |
|
||||||
| `']` 与 `` `] `` | 上一次修改或复制的最后一行或最后一个字符 |
|
| `']` 与 `` `]`` | 上一次修改或复制的最后一行或最后一个字符 |
|
||||||
| `'<` 与 `` `< `` | 上一次在可视模式下选取的第一行或第一个字符 |
|
| `'<` 与 `` `<`` | 上一次在可视模式下选取的第一行或第一个字符 |
|
||||||
| `'>` 与 `` `> `` | 上一次在可视模式下选取的最后一行或最后一个字符 |
|
| `'>` 与 `` `>`` | 上一次在可视模式下选取的最后一行或最后一个字符 |
|
||||||
| `''` 与 `` `' `` | 上一次跳转之前的光标位置 |
|
| `''` 与 `` `'`` | 上一次跳转之前的光标位置 |
|
||||||
| `'"` 与 `` `" `` | 上一次关闭当前缓冲区时的光标位置 |
|
| `'"` 与 `` `"`` | 上一次关闭当前缓冲区时的光标位置 |
|
||||||
| `'^` 与 `` `^ `` | 上一次插入字符后的光标位置 |
|
| `'^` 与 `` `^`` | 上一次插入字符后的光标位置 |
|
||||||
| `'.` 与 `` `. `` | 上一次修改文本后的光标位置 |
|
| `'.` 与 `` `.`` | 上一次修改文本后的光标位置 |
|
||||||
| `'(` 与 `` `( `` | 当前句子的开头 |
|
| `'(` 与 `` `(`` | 当前句子的开头 |
|
||||||
| `')` 与 `` `) `` | 当前句子的结尾 |
|
| `')` 与 `` `)`` | 当前句子的结尾 |
|
||||||
| `'{` 与 `` `{ `` | 当前段落的开头 |
|
| `'{` 与 `` `{`` | 当前段落的开头 |
|
||||||
| `'}` 与 `` `} `` | 当前段落的结尾 |
|
| `'}` 与 `` `}`` | 当前段落的结尾 |
|
||||||
|
|
||||||
标注也可以搭配 [范围](#范围) 一起使用。前面提到过,如果你在可视模式下选取一些文本,然后按下 `:`,这时候你会发现命令行已经被填充了 `:'<,'>`。对照上面的表格,现在你应该明白了,这段代表的就是可视模式下选取的范围。
|
标注也可以搭配 [范围](#范围) 一起使用。前面提到过,如果你在可视模式下选取一些文本,然后按下 `:`,这时候你会发现命令行已经被填充了 `:'<,'>`。对照上面的表格,现在你应该明白了,这段代表的就是可视模式下选取的范围。
|
||||||
|
|
||||||
@ -609,7 +557,7 @@ Vim 在插入模式中为我们提供了多种补全方案。如果有多个补
|
|||||||
|
|
||||||
以下会列出一些常用的动作。你也可以通过 `:h navigation` 来获取更多的帮助。
|
以下会列出一些常用的动作。你也可以通过 `:h navigation` 来获取更多的帮助。
|
||||||
|
|
||||||
**操作符**是对某个区域文本执行的操作。比如,`d`、`~`、`gU` 和 `>` 都是操作符。这些操作符既可以在普通模式下使用,也可以在可视模式下使用。在普通模式中,顺序是先按操作符,再按动作指令,比如 `>j`。在可视模式中,选中区域后直接按操作符就可以,比如 `Vjd`。
|
**操作符**是对某个区域文本执行的操作。比如,`d`、`~`、`gU` 和 `>` 都是操作符。这些操作符既可以在普通模式下使用,也可以在可视模式下使用。在普通模式中,顺序是先按操作符,再按动作指令,比如 `>j`。在可是模式中,选中区域后直接按操作符就可以,比如 `Vjd`。
|
||||||
|
|
||||||
与动作一样,操作符也可以搭配数字使用,比如 `2gUw` 可以将当前单词以及下一个单词转成大写。由于动作和操作符都可以搭配数字使用,因此 `2gU2w` 与执行两次 `gU2w` 效果是相同的。
|
与动作一样,操作符也可以搭配数字使用,比如 `2gUw` 可以将当前单词以及下一个单词转成大写。由于动作和操作符都可以搭配数字使用,因此 `2gU2w` 与执行两次 `gU2w` 效果是相同的。
|
||||||
|
|
||||||
@ -621,7 +569,7 @@ Vim 在插入模式中为我们提供了多种补全方案。如果有多个补
|
|||||||
|
|
||||||
文本对象操作一般用 `i` 或 `a` 加上对象标识符操作,其中 `i` 表示在对象内(英文 inner)操作,`a` 表示对整个对象(英文 around)操作,这时开头和结尾的空格都会被考虑进来。举个例子,`diw` 可以删除当前单词,`ci(` 可以改变括号中的内容。
|
文本对象操作一般用 `i` 或 `a` 加上对象标识符操作,其中 `i` 表示在对象内(英文 inner)操作,`a` 表示对整个对象(英文 around)操作,这时开头和结尾的空格都会被考虑进来。举个例子,`diw` 可以删除当前单词,`ci(` 可以改变括号中的内容。
|
||||||
|
|
||||||
文本对象同样可以与数字搭配使用。比如,像 `((( )))` 这样的文本,假如光标位于最内层的括号上或最内层的括号内,那么 `d2a(` 将会删除从最内层开始的两对括号,以及他们之间的所有内容。其实,`d2a(` 这个操作等同于 `2da(`。在 Vim 的命令中,如果有两处都可以接收数字作为参数,那么最终结果就等同于两个数字相乘。在这里,`d` 与 `a(` 都是可以接收参数的,一个参数是 1,另一个是 2,我们可以把它们相乘然后放到最前面。
|
文本对象同样可以与数字搭配使用。比如,像 `((( )))` 这样的文本,假如光标位于最内层的括号上或最内层的括号内,那么 `d2a(` 将会删除从最内层开始的两对括号,以及他们之间的所有内容。其实,`d2a(` 这个操作等同于 `2da(`。在 Vim 的命令中,如果有两处都可以接收数字作为参数,那么最终结果就等同于两个数字相乘。在这里,`d` 与 `a(` 都是可以接收参数的,一个参数是 1,另一个是 2,我们可以把它们相乘然后放到最前面。
|
||||||
|
|
||||||
请参阅 `:h text-objects` 来获取更多关于文本对象的帮助。
|
请参阅 `:h text-objects` 来获取更多关于文本对象的帮助。
|
||||||
|
|
||||||
@ -693,7 +641,7 @@ Vim 中的跳转命令,包括 `'`、`` ` ``、`G`、`/`、`?`、`n`、`N`、`%
|
|||||||
|
|
||||||
Vim 会记录文本改变之前的状态。因此,你可以使用「撤销」操作 <kbd>u</kbd> 来取消更改,也可以通过「重做」操作 <kbd>Ctrl + r</kbd> 来恢复更改。
|
Vim 会记录文本改变之前的状态。因此,你可以使用「撤销」操作 <kbd>u</kbd> 来取消更改,也可以通过「重做」操作 <kbd>Ctrl + r</kbd> 来恢复更改。
|
||||||
|
|
||||||
值得注意的是,Vim 采用 [tree](<https://en.wikipedia.org/wiki/Tree_(data_structure)>) 数据结构来存储内容变更的历史记录,而不是采用 [queue](<https://en.wikipedia.org/wiki/Queue_(abstract_data_type)>)。你的每次改动都会成为存储为树的节点。而且,除了第一次改动(根节点),之后的每次改动都可以找到一个对应的父节点。每一个节点都会记录改动的内容和时间。其中,「分支」代表从任一节点到根节点的路径。当你进行了撤销操作,然后又输入了新的内容,这时候就相当于创建了分支。这个原理和 git 中的 branch(分支)十分类似。
|
值得注意的是,Vim 采用 [tree](https://en.wikipedia.org/wiki/Tree_(data_structure)) 数据结构来存储内容变更的历史记录,而不是采用 [queue](https://en.wikipedia.org/wiki/Queue_(abstract_data_type))。你的每次改动都会成为存储为树的节点。而且,除了第一次改动(根节点),之后的每次改动都可以找到一个对应的父节点。每一个节点都会记录改动的内容和时间。其中,「分支」代表从任一节点到根节点的路径。当你进行了撤销操作,然后又输入了新的内容,这时候就相当于创建了分支。这个原理和 git 中的 branch(分支)十分类似。
|
||||||
|
|
||||||
考虑以下这一系列按键操作:
|
考虑以下这一系列按键操作:
|
||||||
|
|
||||||
@ -729,7 +677,7 @@ oquux<exc>
|
|||||||
| `[count]g-` 或 `:earlier [count]?` | 根据时间回退到 `[count]` 次改动之前。"?" 为 "s"、"m"、"h"、"d" 或 "f"之一。例如,`:earlier 2d` 会回退到两天之前。`:earlier 1f` 则会回退到最近一次文件保存时的内容 |
|
| `[count]g-` 或 `:earlier [count]?` | 根据时间回退到 `[count]` 次改动之前。"?" 为 "s"、"m"、"h"、"d" 或 "f"之一。例如,`:earlier 2d` 会回退到两天之前。`:earlier 1f` 则会回退到最近一次文件保存时的内容 |
|
||||||
| `[count]g+` 或 `:later [count]?` | 类似 `g-`,但方向相反 |
|
| `[count]g+` 或 `:later [count]?` | 类似 `g-`,但方向相反 |
|
||||||
|
|
||||||
内容变更记录会储存在内存中,当 Vim 退出时就会清空。如果需要持久化存储内容变更记录,请参阅[备份文件,交换文件,撤销文件以及 viminfo 文件的处理](#备份文件交换文件撤销文件以及viminfo文件的处理)章节的内容。
|
内容变更记录会储存在内存中,当 Vim 退出时就会清空。如果需要持久化存储内容变更记录,请参阅[备份文件,交换文件,撤销文件以及viminfo文件的处理](#备份文件交换文件撤销文件以及viminfo文件的处理)章节的内容。
|
||||||
|
|
||||||
如果你觉得这一部分的内容难以理解,请参阅 [undotree](https://github.com/mbbill/undotree),这是一个可视化管理内容变更历史记录的插件。类似的还有 [vim-mundo](https://github.com/simnalamburt/vim-mundo)。
|
如果你觉得这一部分的内容难以理解,请参阅 [undotree](https://github.com/mbbill/undotree),这是一个可视化管理内容变更历史记录的插件。类似的还有 [vim-mundo](https://github.com/simnalamburt/vim-mundo)。
|
||||||
|
|
||||||
@ -788,7 +736,7 @@ Vim 中,全局位置信息表只能有一个,但每一个窗口都可以有
|
|||||||
- 如果你想调用刚才录制的宏,只需要 `[count]@q`
|
- 如果你想调用刚才录制的宏,只需要 `[count]@q`
|
||||||
- 如果你想调用上一次使用的宏,只需要 `[count]@@`
|
- 如果你想调用上一次使用的宏,只需要 `[count]@@`
|
||||||
|
|
||||||
**实例 1**:
|
**实例1**:
|
||||||
|
|
||||||
一个插入字符串 "abc" 后换行的宏,重复调用十次:
|
一个插入字符串 "abc" 后换行的宏,重复调用十次:
|
||||||
|
|
||||||
@ -801,7 +749,7 @@ q
|
|||||||
|
|
||||||
(对于上面这个功能,你同样可以通过如下的按键: <kbd>o</kbd><kbd>a</kbd><kbd>b</kbd><kbd>c</kbd> 然后 <kbd>ESC</kbd> 然后 <kbd>1</kbd><kbd>0</kbd><kbd>.</kbd> 来实现)。
|
(对于上面这个功能,你同样可以通过如下的按键: <kbd>o</kbd><kbd>a</kbd><kbd>b</kbd><kbd>c</kbd> 然后 <kbd>ESC</kbd> 然后 <kbd>1</kbd><kbd>0</kbd><kbd>.</kbd> 来实现)。
|
||||||
|
|
||||||
**实例 2**:
|
**实例2**:
|
||||||
|
|
||||||
一个在每行前都加上行号的宏。从第一行开始,行号为 1,后面依次递增。我们可以通过 <kbd>Ctrl</kbd> + <kbd>a</kbd> 来实现递增的行号,在定义宏的时候,它会显示成 `^A`。
|
一个在每行前都加上行号的宏。从第一行开始,行号为 1,后面依次递增。我们可以通过 <kbd>Ctrl</kbd> + <kbd>a</kbd> 来实现递增的行号,在定义宏的时候,它会显示成 `^A`。
|
||||||
|
|
||||||
@ -954,7 +902,7 @@ Vim 自带了一套很完善的帮助文档,它们是一个个有固定排版
|
|||||||
|
|
||||||
经过一些微小的改动后,重新发布到了这里。
|
经过一些微小的改动后,重新发布到了这里。
|
||||||
|
|
||||||
---
|
* * *
|
||||||
|
|
||||||
如果你知道你想要找什么,使用帮助系统的搜索会更简单一些,因为搜索出的主题都带有固定的格式。
|
如果你知道你想要找什么,使用帮助系统的搜索会更简单一些,因为搜索出的主题都带有固定的格式。
|
||||||
|
|
||||||
@ -970,13 +918,13 @@ Vim 自带了一套很完善的帮助文档,它们是一个个有固定排版
|
|||||||
|
|
||||||
3. 正则表达式以“/”开头,所以 `:h /\+` 会带你到正则表达式中量词“+”的帮助页面。
|
3. 正则表达式以“/”开头,所以 `:h /\+` 会带你到正则表达式中量词“+”的帮助页面。
|
||||||
|
|
||||||
4. 组合键经常以一个字母开头表示它们可以在哪些模式中使用。如:`:h i_CTRL-X` 会带你到插入模式下的 CTRL-X 命令的用法帮助页面,这是一个自动完成类的组合键。需要注意的是某些键是有固定写法的,如 Control 键写成 CTRL。还有,查找普通模式下的组合键帮助时,可以省略开头的字母“n”,如:`:h CTRL-A`。而 `:h c_CTRL-A`(译者注:原文为 `:h c_CRTL-R`,感觉改为 A 更符合上下文语境)会解释 CTRL-A 在命令模式下输入命令时的作用;`:h v_CTRL-A` 说的是在可见模式下把光标所在处的数字加 1;`:h g_CTRL-A` 则说的是 g 命令(你需要先按 "g" 的命令)。这里的 "g" 代表一个普通的命令,这个命令总是与其它的按键组合使用才生效,与 "z" 开始的命令相似。
|
4. 组合键经常以一个字母开头表示它们可以在哪些模式中使用。如:`:h i_CTRL-X` 会带你到插入模式下的 CTRL-X 命令的用法帮助页面,这是一个自动完成类的组合键。需要注意的是某些键是有固定写法的,如Control键写成CTRL。还有,查找普通模式下的组合键帮助时,可以省略开头的字母“n”,如:`:h CTRL-A`。而 `:h c_CTRL-A`(译者注:原文为 `:h c_CRTL-R`,感觉改为 A 更符合上下文语境)会解释 CTRL-A 在命令模式下输入命令时的作用;`:h v_CTRL-A` 说的是在可见模式下把光标所在处的数字加 1;`:h g_CTRL-A` 则说的是 g 命令(你需要先按 "g" 的命令)。这里的 "g" 代表一个普通的命令,这个命令总是与其它的按键组合使用才生效,与 "z" 开始的命令相似。
|
||||||
|
|
||||||
5. 寄存器是以 "quote" 开头的。如:`:h quote:` (译者注:原文为`:h quote`,感觉作者想以":"来举例)来查看关于":"寄存器的说明。
|
5. 寄存器是以 "quote" 开头的。如:`:h quote:` (译者注:原文为`:h quote`,感觉作者想以":"来举例)来查看关于":"寄存器的说明。
|
||||||
|
|
||||||
6. 关于 Vim 脚本(VimL)的帮助都在 `:h eval.txt` 里。而某些方面的语言可以使用 `:h expr-X` 获取帮助,其中的 'X' 是一个特定的字符,如:`:h expr-!` 会跳转到描述 VimL 中'!'(非)的章节。另外一个重要提示,可以使用 `:h function-list` 来查看所有函数的简要描述,列表中包括函数名和一句话描述。
|
6. 关于 Vim 脚本(VimL)的帮助都在 `:h eval.txt` 里。而某些方面的语言可以使用 `:h expr-X` 获取帮助,其中的 'X' 是一个特定的字符,如:`:h expr-!` 会跳转到描述 VimL 中'!'(非)的章节。另外一个重要提示,可以使用 `:h function-list` 来查看所有函数的简要描述,列表中包括函数名和一句话描述。
|
||||||
|
|
||||||
7. 关于映射都可以在 `:h map.txt` 中找到。通过 `:h mapmode-i` 来查找 `:imap` 命令的相关信息;通过 `:h map-topic` 来查找专门针对映射的帮助(译者注:topic 为一个占位符,正如上面的字符 'X' 一样,在实际使用中需要替换成相应的单词)(如:`:h :map-local` 查询本地 buffer 的映射,`:h map-bar` 查询如何在映射中处理'|')。
|
7. 关于映射都可以在 `:h map.txt` 中找到。通过 `:h mapmode-i` 来查找 `:imap` 命令的相关信息;通过 `:h map-topic` 来查找专门针对映射的帮助(译者注:topic 为一个占位符,正如上面的字符 'X' 一样,在实际使用中需要替换成相应的单词)(如:`:h :map-local` 查询本地buffer的映射,`:h map-bar` 查询如何在映射中处理'|')。
|
||||||
|
|
||||||
8. 命令定义用 "command-" 开头,如用 `:h command-bar` 来查看自定义命令中'!'的作用。
|
8. 命令定义用 "command-" 开头,如用 `:h command-bar` 来查看自定义命令中'!'的作用。
|
||||||
|
|
||||||
@ -990,7 +938,7 @@ Vim 自带了一套很完善的帮助文档,它们是一个个有固定排版
|
|||||||
|
|
||||||
13. `:h helphelp` 里介绍了如何使用帮助系统。
|
13. `:h helphelp` 里介绍了如何使用帮助系统。
|
||||||
|
|
||||||
14. 用户手册。它采用了一种对初学者更加友好的方式来展示帮助话题。用 `:h usr_toc.txt` 打开目录(你可能已经猜到这个命令的用处了)。浏览用户手册能帮助你找出某些你想了解的话题,如你可以在第 24 章看到关于“复合字符”以及“输入特殊字符”的讲解(用 `:h usr_24.txt` 可以快速打开相关章节)。
|
14. 用户手册。它采用了一种对初学者更加友好的方式来展示帮助话题。用 `:h usr_toc.txt` 打开目录(你可能已经猜到这个命令的用处了)。浏览用户手册能帮助你找出某些你想了解的话题,如你可以在第24章看到关于“复合字符”以及“输入特殊字符”的讲解(用 `:h usr_24.txt` 可以快速打开相关章节)。
|
||||||
|
|
||||||
15. 高亮分组的帮助以 `hl-` 开头。如:`:h hl-WarningMsg` 说的是警告信息分组的高亮。
|
15. 高亮分组的帮助以 `hl-` 开头。如:`:h hl-WarningMsg` 说的是警告信息分组的高亮。
|
||||||
|
|
||||||
@ -1006,7 +954,7 @@ Vim 自带了一套很完善的帮助文档,它们是一个个有固定排版
|
|||||||
|
|
||||||
21. 错误代码可以在帮助系统中直接查到。`:h E297` 会带你到关于这一错误的详细解释。但是有时并没有转到错误描述,而是列出了经常导出这一错误的 Vim 命令,如 `:h E128` (译者注:原文为`:h hE128`,但是并没有该帮助)会直接跳转到 `:function` 命令。
|
21. 错误代码可以在帮助系统中直接查到。`:h E297` 会带你到关于这一错误的详细解释。但是有时并没有转到错误描述,而是列出了经常导出这一错误的 Vim 命令,如 `:h E128` (译者注:原文为`:h hE128`,但是并没有该帮助)会直接跳转到 `:function` 命令。
|
||||||
|
|
||||||
22. 关于包含的语法文件的文档的帮助话题格式是 `:h ft-*-syntax`。如:`:h ft-c-syntax` 说的就是 C 语言语法文件以及它所提供的选项。有的语法文件还会带有自动完成(`:h ft-php-omni`)或文件类型插件(`:h ft-tex-plugin`)相关的章节可以查看。
|
22. 关于包含的语法文件的文档的帮助话题格式是 `:h ft-*-syntax`。如:`:h ft-c-syntax` 说的就是C语言语法文件以及它所提供的选项。有的语法文件还会带有自动完成(`:h ft-php-omni`)或文件类型插件(`:h ft-tex-plugin`)相关的章节可以查看。
|
||||||
|
|
||||||
另外在每个帮助页的顶端通常会包含一个用户文档链接(更多的从从用户的角度出发来主角命令的功能和用法,不涉及那么多细节)。如:`:h pattern.txt` 里包含了 `:h 03.9` 和 `:h usr_27` 两个章节的链接。
|
另外在每个帮助页的顶端通常会包含一个用户文档链接(更多的从从用户的角度出发来主角命令的功能和用法,不涉及那么多细节)。如:`:h pattern.txt` 里包含了 `:h 03.9` 和 `:h usr_27` 两个章节的链接。
|
||||||
|
|
||||||
@ -1032,7 +980,7 @@ function! Chibby()
|
|||||||
endfunction
|
endfunction
|
||||||
```
|
```
|
||||||
|
|
||||||
现在你插件的用户可以在 Chibby 执行完成之后做任何他想做的事情:
|
现在你插件的用户可以在Chibby执行完成之后做任何他想做的事情:
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
autocmd User ChibbyExit call ChibbyCleanup()
|
autocmd User ChibbyExit call ChibbyCleanup()
|
||||||
@ -1072,7 +1020,7 @@ autocmd VimEnter * nested edit $MYVIMRC
|
|||||||
|
|
||||||
## 剪切板
|
## 剪切板
|
||||||
|
|
||||||
如果你想在没有 GUI 支持的 Unix 系统中使用 Vim 的 `'clipboard'` 选项,则需要 `+clipboard` 以及可选的 `+xterm_clipboard` 两个[特性](#what-kind-of-vim-am-i-running)支持。
|
如果你想在没有GUI支持的Unix系统中使用 Vim 的 `'clipboard'` 选项,则需要 `+clipboard` 以及可选的 `+xterm_clipboard` 两个[特性](#what-kind-of-vim-am-i-running)支持。
|
||||||
|
|
||||||
帮助文档:
|
帮助文档:
|
||||||
|
|
||||||
@ -1086,7 +1034,7 @@ autocmd VimEnter * nested edit $MYVIMRC
|
|||||||
|
|
||||||
### 剪贴板的使用(Windows, OSX)
|
### 剪贴板的使用(Windows, OSX)
|
||||||
|
|
||||||
Windows 自带了[剪贴板](<https://msdn.microsoft.com/en-us/library/windows/desktop/ms649012(v=vs.85).aspx>),OSX 则带了一个[粘贴板](https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/PasteboardGuide106/Introduction/Introduction.html#//apple_ref/doc/uid/TP40008100-SW1)
|
Windows 自带了[剪贴板](https://msdn.microsoft.com/en-us/library/windows/desktop/ms649012(v=vs.85).aspx),OSX 则带了一个[粘贴板](https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/PasteboardGuide106/Introduction/Introduction.html#//apple_ref/doc/uid/TP40008100-SW1)
|
||||||
|
|
||||||
在这两个系统中都可以用大家习惯用的 `ctrl+c / cmd+c` 复制选择的文本,然后在另外一个应用中用 `ctrl+v / cmd+v` 进行粘贴。
|
在这两个系统中都可以用大家习惯用的 `ctrl+c / cmd+c` 复制选择的文本,然后在另外一个应用中用 `ctrl+v / cmd+v` 进行粘贴。
|
||||||
|
|
||||||
@ -1121,7 +1069,7 @@ set guioptions+=a
|
|||||||
|
|
||||||
### 剪贴板的使用(Linux, BSD, ...)
|
### 剪贴板的使用(Linux, BSD, ...)
|
||||||
|
|
||||||
如果你的系统使用了 [X 图形界面](http://www.x.org/wiki),事情会变得有一点不同。X 图形界面实现了 [X 窗口系统协议](http://www.x.org/releases/X11R7.7/doc/xproto/x11protocol.html), 这个协议在 1987 年发布的主版本 11,因此 X 也通常被称为 X11。
|
如果你的系统使用了 [X 图形界面](http://www.x.org/wiki),事情会变得有一点不同。X 图形界面实现了 [X 窗口系统协议](http://www.x.org/releases/X11R7.7/doc/xproto/x11protocol.html), 这个协议在1987年发布的主版本11,因此 X 也通常被称为 X11。
|
||||||
|
|
||||||
在 X10 版本中,[剪贴缓冲区](http://www.x.org/releases/X11R7.7/doc/xorg-docs/icccm/icccm.html#Peer_to_Peer_Communication_by_Means_of_Cut_Buffers)被用来实现像 _clipboard_ 一样由 X 来复制文本,并且可以被所有的程序访问。现在这个机制在 X 中还存在,但是已经过时了,很多程序都不再使用这一机制。
|
在 X10 版本中,[剪贴缓冲区](http://www.x.org/releases/X11R7.7/doc/xorg-docs/icccm/icccm.html#Peer_to_Peer_Communication_by_Means_of_Cut_Buffers)被用来实现像 _clipboard_ 一样由 X 来复制文本,并且可以被所有的程序访问。现在这个机制在 X 中还存在,但是已经过时了,很多程序都不再使用这一机制。
|
||||||
|
|
||||||
@ -1156,7 +1104,7 @@ set clipboard^=unnamedplus " + 寄存器
|
|||||||
|
|
||||||
(`^=` 用来将设置的值加到默认值之前,详见:`:h :set^=`)
|
(`^=` 用来将设置的值加到默认值之前,详见:`:h :set^=`)
|
||||||
|
|
||||||
这会使得所有复制/删除/放入操作使用 `*` 或 `+` 寄存器代替默认的未命令寄存器 `"`。之后你就可以直接使用 `y` 或 `p` 访问你的 X 选择了。
|
这会使得所有复制/删除/放入操作使用 `*` 或 `+` 寄存器代替默认的未命令寄存器 `"`。之后你就可以直接使用 `y` 或 `p` 访问你的X选择了。
|
||||||
|
|
||||||
帮助文档:
|
帮助文档:
|
||||||
|
|
||||||
@ -1178,13 +1126,13 @@ autocmd BufReadPost *
|
|||||||
\ endif
|
\ endif
|
||||||
```
|
```
|
||||||
|
|
||||||
这是通过判断之前的光标位置是否存在(文件可能被其它程序修改而导致所记录的位置已经不存在了),如果存在的话就执行 `` g`" `` (转到你离开时的光标位置但是不更改跳转列表)。
|
这是通过判断之前的光标位置是否存在(文件可能被其它程序修改而导致所记录的位置已经不存在了),如果存在的话就执行 ``g`"`` (转到你离开时的光标位置但是不更改跳转列表)。
|
||||||
|
|
||||||
这需要使用 viminfo 文件:`:h viminfo-`。
|
这需要使用 viminfo 文件:`:h viminfo-`。
|
||||||
|
|
||||||
## 临时文件
|
## 临时文件
|
||||||
|
|
||||||
根据选项的不同, Vim 最多会创建 4 种工作文件。
|
根据选项的不同, Vim 最多会创建4种工作文件。
|
||||||
|
|
||||||
### 备份文件
|
### 备份文件
|
||||||
|
|
||||||
@ -1251,7 +1199,7 @@ set undodir =$HOME/.vim/files/undo/
|
|||||||
set viminfo ='100,n$HOME/.vim/files/info/viminfo
|
set viminfo ='100,n$HOME/.vim/files/info/viminfo
|
||||||
```
|
```
|
||||||
|
|
||||||
注意:如果你在一个多用户系统中编辑某个文件时, Vim 提示你交换文件已经存在的话,可能是因为有其他的用户此时正在编辑这个文件。而如果将交换文件放到自己的 home 目录的话,这个功能就失效了。因此服务器非常不建议将这些文件修改到 HOME 目录,避免多人同时编辑一个文件,却没有任何警告。
|
注意:如果你在一个多用户系统中编辑某个文件时, Vim 提示你交换文件已经存在的话,可能是因为有其他的用户此时正在编辑这个文件。而如果将交换文件放到自己的home目录的话,这个功能就失效了。因此服务器非常不建议将这些文件修改到HOME目录,避免多人同时编辑一个文件,却没有任何警告。
|
||||||
|
|
||||||
## 编辑远程文件
|
## 编辑远程文件
|
||||||
|
|
||||||
@ -1319,23 +1267,23 @@ set virtualedit=all
|
|||||||
|
|
||||||
## 使用外部程序和过滤器
|
## 使用外部程序和过滤器
|
||||||
|
|
||||||
免责声明:Vim 是单线程的,因此在 Vim 中以前端进程执行其它的程序时会阻止其它的一切。当然你可以使用 Vim 程序接口,如 Lua,并且使用它的多线程支持,但是在那期间, Vim 的处理还是被阻止了。Neovim 添加了任务 API 解决了此问题。
|
免责声明:Vim 是单线程的,因此在 Vim 中以前端进程执行其它的程序时会阻止其它的一切。当然你可以使用 Vim 程序接口,如Lua,并且使用它的多线程支持,但是在那期间, Vim 的处理还是被阻止了。Neovim 添加了任务 API 解决了此问题。
|
||||||
|
|
||||||
(据说 Bram 正在考虑在 Vim 中也添加任务控制。如果你使用了较新版本的的 Vim ,可以看一下 `:helpgrep startjob`。)
|
(据说 Bram 正在考虑在 Vim 中也添加任务控制。如果你使用了较新版本的的 Vim ,可以看一下 `:helpgrep startjob`。)
|
||||||
|
|
||||||
使用 `:!` 启动一个新任务。如果你想列出当前工作目录下的所有文件,可以使用 `:!ls`。 用 `|` 来将结果通过管道重定向,如:`:!ls -l | sort | tail -n5`。
|
使用 `:!` 启动一个新任务。如果你想列出当前工作目录下的所有文件,可以使用 `:!ls`。 用 `|` 来将结果通过管道重定向,如:`:!ls -l | sort | tail -n5`。
|
||||||
|
|
||||||
没有使用范围时(译者注:范围就是 `:` 和 `!` 之间的内容,`.` 表示当前行,`+4` 表示向下偏移 4 行,`$` 表示最末行等,多行时用 `,` 将它们分开,如 `.,$` 表示从当前行到末行),`:!` 会显示在一个可滚动的窗口中(译者注:在 GVim 和在终端里运行的结果稍有不同)。相反的,如果指定了范围,这些行会被[过滤](<https://en.wikipedia.org/wiki/Filter_(software)>)。这意味着它们会通过管道被重定向到过滤程序的 [stdin](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_.28stdin.29),在处理后再通过过滤程序的 [stdout](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_.28stdout.29) 输出,用输出结果替换范围内的文本。例如:为接下来的 5 行文本添加行号,可以使用:
|
没有使用范围时(译者注:范围就是 `:` 和 `!` 之间的内容,`.` 表示当前行,`+4` 表示向下偏移4行,`$` 表示最末行等,多行时用 `,` 将它们分开,如 `.,$` 表示从当前行到末行),`:!` 会显示在一个可滚动的窗口中(译者注:在 GVim 和在终端里运行的结果稍有不同)。相反的,如果指定了范围,这些行会被[过滤](https://en.wikipedia.org/wiki/Filter_(software))。这意味着它们会通过管道被重定向到过滤程序的 [stdin](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_.28stdin.29),在处理后再通过过滤程序的 [stdout](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_.28stdout.29) 输出,用输出结果替换范围内的文本。例如:为接下来的5行文本添加行号,可以使用:
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
:.,+4!nl -ba -w1 -s' '
|
:.,+4!nl -ba -w1 -s' '
|
||||||
```
|
```
|
||||||
|
|
||||||
由于手动添加范围很麻烦, Vim 提供了一些辅助方法以方便的添加范围。如果需要经常带着范围的话,你可以在可见模式中先选择,然后再按 `:` (译者注:选中后再按 `!` 更方便)。还可以使用 `!` 来取用一个 motion 的范围,如 `!ipsort` (译者注:原文为 `!ip!sort` ,但经过实验发现该命令执行报错,可能是因为 Vim 版本的原因造成的,新版本使用 `ip` 选择当前段落后自动在命令后添加了 `!` ,按照作者的写法来看,可能之前的版本没有自动添加 `!` )可以将当前段落的所有行按字母表顺序进行排序。
|
由于手动添加范围很麻烦, Vim 提供了一些辅助方法以方便的添加范围。如果需要经常带着范围的话,你可以在可见模式中先选择,然后再按 `:` (译者注:选中后再按 `!` 更方便)。还可以使用 `!` 来取用一个motion的范围,如 `!ipsort` (译者注:原文为 `!ip!sort` ,但经过实验发现该命令执行报错,可能是因为 Vim 版本的原因造成的,新版本使用 `ip` 选择当前段落后自动在命令后添加了 `!` ,按照作者的写法来看,可能之前的版本没有自动添加 `!` )可以将当前段落的所有行按字母表顺序进行排序。
|
||||||
|
|
||||||
一个使用过滤器比较好的案例是[Go 语言](https://golang.org/)。它的缩进语法非常个性,甚至还专门提供了一个名为 `gofmt` 的过滤器来对 Go 语言的源文件进行正确的缩进。Go 语言的插件通常会提供一个名为 `:Fmt` 的函数,这个函数就是执行了 `:%!gofmt` 来对整个文件进行缩进。
|
一个使用过滤器比较好的案例是[Go语言](https://golang.org/)。它的缩进语法非常个性,甚至还专门提供了一个名为 `gofmt` 的过滤器来对Go语言的源文件进行正确的缩进。Go语言的插件通常会提供一个名为 `:Fmt` 的函数,这个函数就是执行了 `:%!gofmt` 来对整个文件进行缩进。
|
||||||
|
|
||||||
人们常用 `:r !prog` 将 prog 程序的插入放到当前行的下面,这对于脚本来说是很不错的选择,但是在使用的过程中我发现 `!!ls` 更加方便,它会用输出结果替换当前行的内容。(译者注:前面命令中的 `prog` 只是个占位符,在实际使用中需要替换成其它的程序,如 `:r !ls`,这就与后面的 `!!ls` 相对应了,两者唯一的不同是第一个命令不会覆盖当前行内容,但是第二个命令会)
|
人们常用 `:r !prog` 将prog程序的插入放到当前行的下面,这对于脚本来说是很不错的选择,但是在使用的过程中我发现 `!!ls` 更加方便,它会用输出结果替换当前行的内容。(译者注:前面命令中的 `prog` 只是个占位符,在实际使用中需要替换成其它的程序,如 `:r !ls`,这就与后面的 `!!ls` 相对应了,两者唯一的不同是第一个命令不会覆盖当前行内容,但是第二个命令会)
|
||||||
|
|
||||||
帮助文档:
|
帮助文档:
|
||||||
|
|
||||||
@ -1346,9 +1294,9 @@ set virtualedit=all
|
|||||||
|
|
||||||
## Cscope
|
## Cscope
|
||||||
|
|
||||||
[Cscope](http://cscope.sourceforge.net/) 的功能比 [ctags](http://ctags.sourceforge.net/) 要完善,但是只支持 C(通过设置 cscope.files 后同样支持 C++以及 Java)。
|
[Cscope](http://cscope.sourceforge.net/) 的功能比 [ctags](http://ctags.sourceforge.net/) 要完善,但是只支持C(通过设置cscope.files后同样支持C++以及Java)。
|
||||||
|
|
||||||
鉴于 Tag 文件只是知道某个符号是在哪里定义的,cscope 的数据库里的数据信息就多的多了:
|
鉴于Tag文件只是知道某个符号是在哪里定义的,cscope的数据库里的数据信息就多的多了:
|
||||||
|
|
||||||
- 符号是在哪里定义的?
|
- 符号是在哪里定义的?
|
||||||
- 符号是在哪里被使用的?
|
- 符号是在哪里被使用的?
|
||||||
@ -1371,7 +1319,7 @@ $ cscope -bqR
|
|||||||
|
|
||||||
这条命令会在当前目录下创建三个文件:`cscope{,.in,.po}.out` 。把它们想象成你的数据库。
|
这条命令会在当前目录下创建三个文件:`cscope{,.in,.po}.out` 。把它们想象成你的数据库。
|
||||||
|
|
||||||
不幸的时 `cscope` 默认只分析 `*.[c|h|y|l]` 文件。如果你想在 Java 项目中使用 cscope ,需要这样做:
|
不幸的时 `cscope` 默认只分析 `*.[c|h|y|l]` 文件。如果你想在Java项目中使用 cscope ,需要这样做:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ find . -name "*.java" > cscope.files
|
$ find . -name "*.java" > cscope.files
|
||||||
@ -1434,7 +1382,7 @@ nnoremap <buffer> <leader>cd :cscope find d <c-r>=expand('<cword>')<cr><cr>
|
|||||||
|
|
||||||
由于 Vim 是用 C 语言编写的,因此许多功能都假设使用类似 C 语言的语法。默认情况下,如果你的光标在 `{` 或 `#endif` , 就可以使用 `%` 跳转到与之匹配的 `}` 或 `#ifdef`。
|
由于 Vim 是用 C 语言编写的,因此许多功能都假设使用类似 C 语言的语法。默认情况下,如果你的光标在 `{` 或 `#endif` , 就可以使用 `%` 跳转到与之匹配的 `}` 或 `#ifdef`。
|
||||||
|
|
||||||
Vim 自带了一个名为 matchit.vim 的插件,但是默认没有启用。启用后可以用 `%` 在 HTML 相匹配的标签或 VimL 的 if/else/endif 块之间进行跳转,它还带来了一些新的命令。
|
Vim 自带了一个名为 matchit.vim 的插件,但是默认没有启用。启用后可以用 `%` 在HTML相匹配的标签或 VimL 的 if/else/endif 块之间进行跳转,它还带来了一些新的命令。
|
||||||
|
|
||||||
### 在 Vim 8 中安装
|
### 在 Vim 8 中安装
|
||||||
|
|
||||||
@ -1450,7 +1398,7 @@ packadd! matchit
|
|||||||
runtime macros/matchit.vim
|
runtime macros/matchit.vim
|
||||||
```
|
```
|
||||||
|
|
||||||
由于 matchit 的文档很全面,我建议安装以后执行一次下面的命令:
|
由于matchit的文档很全面,我建议安装以后执行一次下面的命令:
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
:!mkdir -p ~/.vim/doc
|
:!mkdir -p ~/.vim/doc
|
||||||
@ -1480,15 +1428,6 @@ autocmd FileType python let b:match_words = '\<if\>:\<elif\>:\<else\>'
|
|||||||
|
|
||||||
# 技巧
|
# 技巧
|
||||||
|
|
||||||
## 跳至选择的区域另一端
|
|
||||||
|
|
||||||
在使用 `v` 或者 `V` 选择某段文字后,可以用 `o` 或者 `O` 按键跳至选择区域的开头或者结尾。
|
|
||||||
|
|
||||||
```
|
|
||||||
:h v_o
|
|
||||||
:h v_O
|
|
||||||
```
|
|
||||||
|
|
||||||
## 聪明地使用 n 和 N
|
## 聪明地使用 n 和 N
|
||||||
|
|
||||||
<kbd>n</kbd> 与 <kbd>N</kbd> 的实际跳转方向取决于使用 `/` 还是 `?` 来执行搜索,其中 `/` 是向后搜索,`?` 是向前搜索。一开始我(原作者)觉得这里很难理解。
|
<kbd>n</kbd> 与 <kbd>N</kbd> 的实际跳转方向取决于使用 `/` 还是 `?` 来执行搜索,其中 `/` 是向后搜索,`?` 是向前搜索。一开始我(原作者)觉得这里很难理解。
|
||||||
@ -1553,47 +1492,6 @@ nnoremap ]<space> :<c-u>put =repeat(nr2char(10), v:count1)<cr>
|
|||||||
|
|
||||||
设置之后,连续按下 <kbd>5</kbd> <kbd>\[</kbd> <kbd>空格</kbd> 在当前行上方插入 5 个空行。
|
设置之后,连续按下 <kbd>5</kbd> <kbd>\[</kbd> <kbd>空格</kbd> 在当前行上方插入 5 个空行。
|
||||||
|
|
||||||
### 运行时检测
|
|
||||||
|
|
||||||
需要的特性:+profile
|
|
||||||
|
|
||||||
Vim 提供了一个内置的运行时检查功能,能够找出运行慢的代码。
|
|
||||||
|
|
||||||
`:profile` 命令后面跟着子命令来确定要查看什么。
|
|
||||||
|
|
||||||
如果你想查看所有的:
|
|
||||||
|
|
||||||
```Vim
|
|
||||||
:profile start /tmp/profile.log
|
|
||||||
:profile file *
|
|
||||||
:profile func *
|
|
||||||
<do something in Vim>
|
|
||||||
<quit Vim>
|
|
||||||
```
|
|
||||||
|
|
||||||
Vim 不断地在内存中检查信息,只在退出的时候输出出来。(Neovim 已经解决了这个问题用 `:profile dump` 命令)
|
|
||||||
|
|
||||||
看一下 `/tmp/profile.log` 文件,检查时运行的所有代码都会被显示出来,包括每一行代码运行的频率和时间。
|
|
||||||
|
|
||||||
大多数代码都是用户不熟悉的插件代码,如果你是在解决一个确切的问题,
|
|
||||||
直接跳到这个日志文件的末尾,那里有 `FUNCTIONS SORTED ON TOTAL TIME` 和 `FUNCTIONS SORTED ON SELF TIME` 两个部分,如果某个 function 运行时间过长一眼就可以看到。
|
|
||||||
|
|
||||||
### 查看启动时间
|
|
||||||
|
|
||||||
感觉 Vim 启动的慢?到了研究几个数字的时候了:
|
|
||||||
|
|
||||||
```vim
|
|
||||||
vim --startuptime /tmp/startup.log +q && vim /tmp/startup.log
|
|
||||||
```
|
|
||||||
|
|
||||||
第一栏是最重要的因为它显示了**绝对运行时间**,如果在前后两行之间时间差有很大的跳跃,那么是第二个文件太大或者含有需要检查的错误的 VimL 代码。
|
|
||||||
|
|
||||||
## NUL 符用新行表示
|
|
||||||
|
|
||||||
文件中的 NUL 符 (`\0`),在内存中被以新行(`\n`)保存,在缓存空间中显示为 `^@`。
|
|
||||||
|
|
||||||
更多信息请参看 `man 7 ascii` 和 `:h NL-used-for-Nul` 。
|
|
||||||
|
|
||||||
## 快速编辑自定义宏
|
## 快速编辑自定义宏
|
||||||
|
|
||||||
这个功能真的很实用!下面的映射,就是在一个新的命令行窗口中读取某一个寄存器(默认为 `*`)。当你设置完成后,只需要按下 <kbd>回车</kbd> 即可让它生效。
|
这个功能真的很实用!下面的映射,就是在一个新的命令行窗口中读取某一个寄存器(默认为 `*`)。当你设置完成后,只需要按下 <kbd>回车</kbd> 即可让它生效。
|
||||||
@ -1663,18 +1561,6 @@ xnoremap > >gv
|
|||||||
|
|
||||||
设置好之后,在可视模式中使用 `>>>>>` 就不会再出现上面提到的问题了。
|
设置好之后,在可视模式中使用 `>>>>>` 就不会再出现上面提到的问题了。
|
||||||
|
|
||||||
## 选择当前行至结尾,排除换行符
|
|
||||||
|
|
||||||
在 Vim 里,我们可以同过 `v$` 选择当前行至结尾,但此时会把最后一个换行符也选中,通常需要按额外的 `h` 来取消最后选中最后一个换行符号。
|
|
||||||
Vim 提供了一个 `g_` 快捷键,可以移动光标至最后一个非空字符。因此,为达到次效果,可以使用 `vg_`。当然,如果觉得按三个键比较麻烦,
|
|
||||||
可以添加一个映射:
|
|
||||||
|
|
||||||
```vim
|
|
||||||
nnoremap L g_
|
|
||||||
```
|
|
||||||
|
|
||||||
这样就可以通过 `vL` 达到一样的效果了。
|
|
||||||
|
|
||||||
## 重新载入保存文件
|
## 重新载入保存文件
|
||||||
|
|
||||||
通过[自动命令](#自动命令),你可以在保存文件的同时触发一些其他功能。比如,如果这个文件是一个配置文件,那么就重新载入;或者你还可以对这个文件进行代码风格检查。
|
通过[自动命令](#自动命令),你可以在保存文件的同时触发一些其他功能。比如,如果这个文件是一个配置文件,那么就重新载入;或者你还可以对这个文件进行代码风格检查。
|
||||||
@ -1791,9 +1677,9 @@ autocmd ColorScheme lucius highlight StatusLine ctermbg=darkgray cterm=NONE guib
|
|||||||
|
|
||||||
vim -u NONE -N
|
vim -u NONE -N
|
||||||
|
|
||||||
这样会在不引用 vimrc(默认设置)的情况下重启 vim,并且在 **nocompatible** 模式下(使用 vim 默认设置而不是 vi 的)。(搜索 `:h --noplugin` 命令了解更多启动加载方式)
|
这样会在不引用vimrc(默认设置)的情况下重启vim,并且在 **nocompatible** 模式下(使用vim默认设置而不是vi的)。(搜索 `:h --noplugin` 命令了解更多启动加载方式)
|
||||||
|
|
||||||
如果仍旧能够出现该错误,那么这极有可能是 vim 本身的 bug,请给 [vim_dev]("https://groups.google.com/forum/#!forum/vim_dev") 发送邮件反馈错误,多数情况下问题不会立刻解决,你还需要进一步研究
|
如果仍旧能够出现该错误,那么这极有可能是vim本身的bug,请给 [vim_dev]("https://groups.google.com/forum/#!forum/vim_dev") 发送邮件反馈错误,多数情况下问题不会立刻解决,你还需要进一步研究
|
||||||
|
|
||||||
许多插件经常会提供新的(默认的/自动的)操作。如果在保存的时候发生了,那么请用 `:verb au BufWritePost` 命令检查潜在的问题
|
许多插件经常会提供新的(默认的/自动的)操作。如果在保存的时候发生了,那么请用 `:verb au BufWritePost` 命令检查潜在的问题
|
||||||
|
|
||||||
@ -1803,11 +1689,11 @@ autocmd ColorScheme lucius highlight StatusLine ctermbg=darkgray cterm=NONE guib
|
|||||||
|
|
||||||
到了一行行代码检查的时候了,不断地排除缩小检查范围知道你找出错误,根据二分法的原理你不会花费太多时间的。
|
到了一行行代码检查的时候了,不断地排除缩小检查范围知道你找出错误,根据二分法的原理你不会花费太多时间的。
|
||||||
|
|
||||||
在实践过程中,可能就是这样,把 `:finish` 放在你的 **vimrc** 文件中间,Vim 会跳过它之后的设置。如果问题还在,那么问题就出在`:finish`之前的设置中,再把`:finish`放到前一部分设置的中间位置。否则问题就出现在它后面的半部分设置,那么就把`:finish`放到后半部分的中间位置。不断的重复即可找到。
|
在实践过程中,可能就是这样,把 `:finish` 放在你的 **vimrc** 文件中间,Vim会跳过它之后的设置。如果问题还在,那么问题就出在`:finish`之前的设置中,再把`:finish`放到前一部分设置的中间位置。否则问题就出现在它后面的半部分设置,那么就把`:finish`放到后半部分的中间位置。不断的重复即可找到。
|
||||||
|
|
||||||
## 调整日志等级
|
## 调整日志等级
|
||||||
|
|
||||||
Vim 现在正在使用的另一个比较有用的方法是增加 debug 信息输出详细等级。现在 Vim 支持 9 个等级,可以用`:h 'verbose'`命令查看。
|
Vim现在正在使用的另一个比较有用的方法是增加debug信息输出详细等级。现在Vim支持9个等级,可以用`:h 'verbose'`命令查看。
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
:e /tmp/foo
|
:e /tmp/foo
|
||||||
@ -1818,7 +1704,7 @@ Vim 现在正在使用的另一个比较有用的方法是增加 debug 信息输
|
|||||||
|
|
||||||
这可以显示出所有引用的文件、没有变化的文件或者各种各样的作用于保存的插件。
|
这可以显示出所有引用的文件、没有变化的文件或者各种各样的作用于保存的插件。
|
||||||
|
|
||||||
如果你只是想用简单的命令来提高等级,也是用 `:verbose` ,放在其他命令之前,通过计数来指明等级,默认是 1.
|
如果你只是想用简单的命令来提高等级,也是用 `:verbose` ,放在其他命令之前,通过计数来指明等级,默认是1.
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
:verb set verbose
|
:verb set verbose
|
||||||
@ -1827,7 +1713,7 @@ Vim 现在正在使用的另一个比较有用的方法是增加 debug 信息输
|
|||||||
" verbose=10
|
" verbose=10
|
||||||
```
|
```
|
||||||
|
|
||||||
通常用等级 1 来显示上次从哪里设置的选项
|
通常用等级1来显示上次从哪里设置的选项
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
:verb set ai?
|
:verb set ai?
|
||||||
@ -1840,21 +1726,21 @@ Vim 现在正在使用的另一个比较有用的方法是增加 debug 信息输
|
|||||||
:set verbosefile=/tmp/foo | 15verbose echo "foo" | vsplit /tmp/foo
|
:set verbosefile=/tmp/foo | 15verbose echo "foo" | vsplit /tmp/foo
|
||||||
```
|
```
|
||||||
|
|
||||||
你可以一开始的时候就打开 verbosity,用 `-V` 选项,它默认设置调试等级为 10。 例如:`vim -V5`
|
你可以一开始的时候就打开verbosity,用 `-V` 选项,它默认设置调试等级为10。 例如:`vim -V5`
|
||||||
|
|
||||||
## 查看启动日志
|
## 查看启动日志
|
||||||
|
|
||||||
## 查看运行时日志
|
## 查看运行时日志
|
||||||
|
|
||||||
## Vim 脚本调试
|
## Vim脚本调试
|
||||||
|
|
||||||
如果你以前使用过命令行调试器的话,对于`:debug`命令你很快就会感到熟悉。
|
如果你以前使用过命令行调试器的话,对于`:debug`命令你很快就会感到熟悉。
|
||||||
|
|
||||||
只需要在任何其他命令之前加上`:debug`就会让你进入调试模式。也就是,被调试的 Vim 脚本会在第一行停止运行,同时该行会被显示出来。
|
只需要在任何其他命令之前加上`:debug`就会让你进入调试模式。也就是,被调试的Vim脚本会在第一行停止运行,同时该行会被显示出来。
|
||||||
|
|
||||||
想了解可用的 6 个调试命令,可以查阅`:h >cont`和阅读下面内容。需要指出的是,类似 gdb 和其他相似调试器,调试命令可以使用它们的简短形式:`c`、 `q`、`n`、`s`、 `i`和 `f`。
|
想了解可用的6个调试命令,可以查阅`:h >cont`和阅读下面内容。需要指出的是,类似gdb和其他相似调试器,调试命令可以使用它们的简短形式:`c`、 `q`、`n`、`s`、 `i`和 `f`。
|
||||||
|
|
||||||
除了上面的之外,你还可以自由地使用任何 Vim 的命令。比如,`:echo myvar`,该命令会在当前的脚本代码位置和上下文上被执行。
|
除了上面的之外,你还可以自由地使用任何Vim的命令。比如,`:echo myvar`,该命令会在当前的脚本代码位置和上下文上被执行。
|
||||||
|
|
||||||
只需要简单使用`:debug 1`,你就获得了[REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop)调试特性。
|
只需要简单使用`:debug 1`,你就获得了[REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop)调试特性。
|
||||||
|
|
||||||
@ -1886,9 +1772,10 @@ Vim 现在正在使用的另一个比较有用的方法是增加 debug 信息输
|
|||||||
|
|
||||||
`:debug`命令可以和[verbose](#verbosity)选项一起使用。
|
`:debug`命令可以和[verbose](#verbosity)选项一起使用。
|
||||||
|
|
||||||
|
|
||||||
## 语法文件调试
|
## 语法文件调试
|
||||||
|
|
||||||
语法文件由于包含错误的或者复制的正则表达式,常常会使得 Vim 的运行较慢。如果 Vim 在编译的时候包含了`+profile` [feature](#what-kind-of-vim-am-i-running)特性,就可以给用户提供一个超级好用的`:syntime`命令。
|
语法文件由于包含错误的或者复制的正则表达式,常常会使得Vim的运行较慢。如果Vim在编译的时候包含了`+profile` [feature](#what-kind-of-vim-am-i-running)特性,就可以给用户提供一个超级好用的`:syntime`命令。
|
||||||
|
|
||||||
```vim
|
```vim
|
||||||
:syntime on
|
:syntime on
|
||||||
@ -1896,11 +1783,12 @@ Vim 现在正在使用的另一个比较有用的方法是增加 debug 信息输
|
|||||||
:syntime off
|
:syntime off
|
||||||
:syntime report
|
:syntime report
|
||||||
```
|
```
|
||||||
|
|
||||||
输出结果包含了很多的度量维度。比如,你可以通过结果知道哪些正则表达式耗时太久需要被优化;哪些正则表达式一直在别使用但重来没有一次成功匹配。
|
输出结果包含了很多的度量维度。比如,你可以通过结果知道哪些正则表达式耗时太久需要被优化;哪些正则表达式一直在别使用但重来没有一次成功匹配。
|
||||||
|
|
||||||
请查阅`:h :syntime`。
|
请查阅`:h :syntime`。
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# 杂项
|
# 杂项
|
||||||
|
|
||||||
## 附加资源
|
## 附加资源
|
||||||
@ -1908,23 +1796,23 @@ Vim 现在正在使用的另一个比较有用的方法是增加 debug 信息输
|
|||||||
| 资源名称 | 简介 |
|
| 资源名称 | 简介 |
|
||||||
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- |
|
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- |
|
||||||
| [七个高效的文本编辑习惯](http://www.moolenaar.net/habits.html) | 作者:Bram Moolenaar(即 Vim 的作者) |
|
| [七个高效的文本编辑习惯](http://www.moolenaar.net/habits.html) | 作者:Bram Moolenaar(即 Vim 的作者) |
|
||||||
| [七个高效的文本编辑习惯 2.0(PDF 版)](http://www.moolenaar.net/habits_2007.pdf) | 同上 |
|
| [七个高效的文本编辑习惯2.0(PDF版)](http://www.moolenaar.net/habits_2007.pdf) | 同上 |
|
||||||
| [IBM DeveloperWorks: 使用脚本编写 Vim 编辑器](http://www.ibm.com/developerworks/views/linux/libraryview.jsp?sort_order=asc&sort_by=Title&search_by=scripting+the+vim+editor) | Vim 脚本编写五辑 |
|
| [IBM DeveloperWorks: 使用脚本编写 Vim 编辑器](http://www.ibm.com/developerworks/views/linux/libraryview.jsp?sort_order=asc&sort_by=Title&search_by=scripting+the+vim+editor) | Vim 脚本编写五辑 |
|
||||||
| [《漫漫 Vim 路》](http://learnvimscriptthehardway.stevelosh.com) | 使用魔抓定制 Vim 插件 |
|
| [《漫漫 Vim 路》](http://learnvimscriptthehardway.stevelosh.com) | 使用魔抓定制 Vim 插件 |
|
||||||
| [《 Vim 实践 (第 2 版)》](http://www.amazon.com/Practical-Vim-Edit-Speed-Thought/dp/1680501275/) | 轻取 Vim 最佳书籍 |
|
| [《 Vim 实践 (第2版)》](http://www.amazon.com/Practical-Vim-Edit-Speed-Thought/dp/1680501275/) | 轻取 Vim 最佳书籍 |
|
||||||
| [Vimcasts.org](http://vimcasts.org/episodes/archive) | Vim 录屏演示 |
|
| [Vimcasts.org](http://vimcasts.org/episodes/archive) | Vim录屏演示 |
|
||||||
| [为什么是个脚本都用 vi?](http://www.viemu.com/a-why-vi-vim.html) | 常见误区释疑 |
|
| [为什么是个脚本都用 vi?](http://www.viemu.com/a-why-vi-vim.html) | 常见误区释疑 |
|
||||||
| [你不爱 vi,所以你不懂 Vim ](http://stackoverflow.com/a/1220118) | 简明,扼要,准确的干货 |
|
| [你不爱 vi,所以你不懂 Vim ](http://stackoverflow.com/a/1220118) | 简明,扼要,准确的干货 |
|
||||||
|
|
||||||
## Vim 配置集合
|
## Vim 配置集合
|
||||||
|
|
||||||
目前,网上有很多流行 Vim 配置集合,对于 Vim 配置集合,个人认为有利有弊。
|
## 内置插件
|
||||||
对于维护的比较好的配置,比如 [SpaceVim](http://spacevim.org/cn/) 还是值得尝试的,可以节省很多自行配置的时间。
|
|
||||||
当然,网上还有很多其他很流行的配置,比如:
|
|
||||||
|
|
||||||
- [k-vim](https://github.com/wklken/k-vim)
|
## 将 Control 映射到 CapsLock
|
||||||
- [amix's vimrc](https://github.com/amix/vimrc)
|
|
||||||
- [janus](https://github.com/carlhuda/janus)
|
## 复活节彩蛋
|
||||||
|
|
||||||
|
## 为何使用 hjkl
|
||||||
|
|
||||||
## 常见问题
|
## 常见问题
|
||||||
|
|
||||||
@ -1973,10 +1861,7 @@ $ vim -n -u NONE -i NONE -N
|
|||||||
|
|
||||||
你有没有遇到过往 Vim 里粘贴代码之后被搞的一团糟?
|
你有没有遇到过往 Vim 里粘贴代码之后被搞的一团糟?
|
||||||
|
|
||||||
这在你使用 `cmd+v`、`shirt-insert`、`middle-click` 等进行粘贴的时候才会发生。
|
这在你使用 `cmd+v`、`shirt-insert`、`middle-click` 等进行粘贴的时候才会发生。因为那样的话你只是向终端模拟器扔了一大堆的文本。 Vim 并不知道你刚刚是粘贴的文本,它以为你在飞速的输入。于是它想缩进这些行但是失败了。
|
||||||
因为那样的话你只是向终端模拟器扔了一大堆的文本。
|
|
||||||
Vim 并不知道你刚刚是粘贴的文本,它以为你在飞速的输入。
|
|
||||||
于是它想缩进这些行但是失败了。
|
|
||||||
|
|
||||||
这明显不是个问题,如果你用 Vim 的寄存器粘贴,如:`"+p` ,这时 Vim 就知道了你在粘贴,就不会导致格式错乱了。
|
这明显不是个问题,如果你用 Vim 的寄存器粘贴,如:`"+p` ,这时 Vim 就知道了你在粘贴,就不会导致格式错乱了。
|
||||||
|
|
||||||
@ -2001,7 +1886,7 @@ Neovim 尝试把这些变得更顺畅,如果终端支持的话,它会自动
|
|||||||
:nnoremap ,ab :echo 'bar'<cr>
|
:nnoremap ,ab :echo 'bar'<cr>
|
||||||
```
|
```
|
||||||
|
|
||||||
上面的例子中两个映射都能正常工作,但是当输入 `,a` 之后,Vim 会延时 1 秒,因为它要确认用户是否还要输入那个 `b`。
|
上面的例子中两个映射都能正常工作,但是当输入 `,a` 之后,Vim 会延时1秒,因为它要确认用户是否还要输入那个 `b`。
|
||||||
|
|
||||||
转义序列会产生同样的问题:
|
转义序列会产生同样的问题:
|
||||||
|
|
||||||
@ -2037,15 +1922,13 @@ set ttimeoutlen=10 " unnoticeable small value
|
|||||||
|
|
||||||
帮助文档:`:h function-search-undo`。
|
帮助文档:`:h function-search-undo`。
|
||||||
|
|
||||||
## 进阶阅读
|
## [插件列表](PLUGINS.md)
|
||||||
|
|
||||||
- [Vim 插件开发指南](https://github.com/wsdjeg/vim-plugin-dev-guide)
|
|
||||||
- [常用插件列表](PLUGINS.md)
|
|
||||||
|
|
||||||
## 加入我们
|
## 加入我们
|
||||||
|
|
||||||
可以协助我们核对翻译,或者从[章节列表](CONTRIBUTING.md)中认领章节进行翻译。
|
可以协助我们核对翻译,或者从[章节列表](CONTRIBUTING.md)中认领章节进行翻译。
|
||||||
|
|
||||||
## 参考资料
|
## 致谢:
|
||||||
|
|
||||||
- [Nifty Little Nvim Techniques to Make My Life Easier -- Series 1](https://jdhao.github.io/2019/03/28/nifty_nvim_techniques_s1/)
|
- [Linux 中国翻译组](https://github.com/LCTT)
|
||||||
|
- [掘金翻译计划](https://github.com/xitu/gold-miner)
|
||||||
|
7
chapter/Debugging.md
Normal file
7
chapter/Debugging.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
## Debugging
|
||||||
|
- 常用技巧
|
||||||
|
- 复杂度
|
||||||
|
- 查看启动时间
|
||||||
|
- 运行时检测
|
||||||
|
- 检查Vim脚本
|
||||||
|
- 检查语法文件
|
6
chapter/Newline-Used-For-NUL.md
Executable file
6
chapter/Newline-Used-For-NUL.md
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
## 新行用于NUL
|
||||||
|
|
||||||
|
一个文件中的NUL字符(`\0`),是以换行符(`\n`)在内存中被存储的同时在显示的时候以`^@`呈现。
|
||||||
|
|
||||||
|
查阅`man 7 ascii`和`:h NL-used-for-Nul`获取更多相关信息。
|
||||||
|
|
23
chapter/Profiling-at-runtime.md
Normal file
23
chapter/Profiling-at-runtime.md
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
### 运行时检测
|
||||||
|
|
||||||
|
需要的特性:+profile
|
||||||
|
|
||||||
|
Vim 提供了一个内置的运行时检查功能,能够找出运行慢的代码。
|
||||||
|
|
||||||
|
```:profile``` 命令后面跟着子命令来确定要查看什么。
|
||||||
|
|
||||||
|
如果你想查看所有的:
|
||||||
|
|
||||||
|
```Vim
|
||||||
|
:profile start /tmp/profile.log
|
||||||
|
:profile file *
|
||||||
|
:profile func *
|
||||||
|
<do something in Vim>
|
||||||
|
<quit Vim>
|
||||||
|
```
|
||||||
|
|
||||||
|
Vim 不断地在内存中检查信息,只在退出的时候输出出来。(Neovim 已经解决了这个问题用 ```:profile dump``` 命令)
|
||||||
|
|
||||||
|
看一下 ```/tmp/profile.log``` 文件,检查时运行的所有代码都会被显示出来,包括每一行代码运行的频率和时间。
|
||||||
|
|
||||||
|
大多数代码都是用户不熟悉的插件代码,如果你是在解决一个确切的问题,直接跳到这个日志文件的末尾,那里有 ```FUNCTIONS SORTED ON TOTAL TIME``` 和 ```FUNCTIONS SORTED ON SELF TIME``` 两个部分,如果某个function运行时间过长一眼就可以看到。
|
10
chapter/Profiling-startup-time.md
Normal file
10
chapter/Profiling-startup-time.md
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
### 查看启动时间
|
||||||
|
|
||||||
|
感觉Vim启动的慢?到了研究几个数字的时候了:
|
||||||
|
|
||||||
|
```vim
|
||||||
|
vim --startuptime /tmp/startup.log +q && vim /tmp/startup.log
|
||||||
|
```
|
||||||
|
|
||||||
|
第一栏是最重要的因为它显示了**绝对运行时间**,如果在前后两行之间时间差有很大的跳跃,那么是第二个文件太大或者含有需要检查的错误的VimL代码。
|
||||||
|
|
@ -1,8 +1,3 @@
|
|||||||
# 技术怪癖
|
# 技术怪癖
|
||||||
|
|
||||||
## NUL 符用新行表示
|
## NUL 符用新行表示
|
||||||
|
|
||||||
文件中的 NUL 符 (`\0`) 在内存中会被存储为换行符 (`\n`) 且
|
|
||||||
在缓冲区中显示为 `^@`.
|
|
||||||
|
|
||||||
在 `man 7 ascii` 和 `:h NL-used-for-Nul` 中查看更多信息。
|
|
||||||
|
@ -1,18 +1,18 @@
|
|||||||
## 粘贴归类 (要不为什么我总要设置‘粘贴’?)
|
## 粘贴归类 (要不为什么我总要设置‘粘贴’?)
|
||||||
|
|
||||||
粘贴归类模式使得终端虚拟器可以区分键入文本和粘贴文本。
|
粘贴归类模式使得终端虚拟器可以区分键入文本和粘贴文本。
|
||||||
|
|
||||||
你是否曾经尝试过向 Vim 粘贴过代码,结果弄得一团糟?
|
你是否曾经尝试过向 Vim 粘贴过代码,结果弄得一团糟?
|
||||||
|
|
||||||
这只会在你通过 `cmd+v`, `shift-insert`, `middle-click` 等等命令进行粘贴时发生。
|
这只会在你通过 `cmd+v`, `shift-insert`, `middle-click` 等等命令进行粘贴时发生。
|
||||||
因为那时你只是在向终端虚拟器里丢文本。Vim 并不知道你在粘贴文本,它天真地认为你是一个熟练的打字员。因此,它尝试排版,但是失败了。
|
因为那时你只是在向终端虚拟器里丢文本。Vim 并不知道你在粘贴文本,它天真地认为你是一个熟练的打字员。因此,它尝试排版,但是失败了。
|
||||||
|
|
||||||
如果你使用 Vim 命令集里的粘贴,比如 `"+p` ,那这就不会成为问题,因为 Vim 知道你做的是粘贴操作。
|
如果你使用 Vim 命令集里的粘贴,比如 `"+p` ,那这就不会成为问题,因为 Vim 知道你做的是粘贴操作。
|
||||||
|
|
||||||
为了解决这个,你需要设置粘贴 `:set paste` ,以便获取粘贴现状。 参考 `:h 'paste'` 和 `:h 'pastetoggle'`.
|
为了解决这个,你需要设置粘贴 `:set paste` ,以便获取粘贴现状。 参考 `:h 'paste'` 和 `:h 'pastetoggle'`.
|
||||||
|
|
||||||
如果你已经受够了不停地切换 `'paste'` ,看一看这个不错的插件能为你做什么:[粘贴归类](https://github.com/ConradIrwin/vim-bracketed-paste)。
|
如果你已经受够了不停地切换 `'paste'` ,看一看这个不错的插件能为你做什么:[粘贴归类](https://github.com/ConradIrwin/vim-bracketed-paste)。
|
||||||
|
|
||||||
插件作者的拓展阅读:[欢迎点击](http://cirw.in/blog/bracketed-paste).
|
插件作者的拓展阅读:[欢迎点击](http://cirw.in/blog/bracketed-paste).
|
||||||
|
|
||||||
**Neovim**: Neovim 努力无缝地完成这些工作,并在终端虚拟器支持时自动设定粘贴归类模式。
|
**Neovim**: Neovim 努力无缝地完成这些工作,并在终端虚拟器支持时自动设定粘贴归类模式。
|
||||||
|
44
chapter/delays-when-using-escape-key-in-terminal.md
Normal file
44
chapter/delays-when-using-escape-key-in-terminal.md
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
## 使用终端中 Esc 键时的延迟
|
||||||
|
|
||||||
|
如果你生活在命令行里,你可能使用 xterm, gnome-terminal, iTerm2 等等所谓的 _终端虚拟器_。(区别于真正的[终端](https://en.wikipedia.org/wiki/Computer_terminal))
|
||||||
|
|
||||||
|
和宿主终端一样,终端虚拟器使用 [退出序列](https://en.wikipedia.org/wiki/Escape_sequence) (或者叫 _控制序列_)来控制光标移动,更换文本颜色等等。
|
||||||
|
退出序列是一些以退出码(在 [插入符号](https://en.wikipedia.org/wiki/Caret_notation) 中展示为 `^[`)开头的 ASCII 码串。
|
||||||
|
当接收到码串时,终端虚拟器会从 [terminfo](https://en.wikipedia.org/wiki/Terminfo) 数据库中寻找与之匹配的指令。
|
||||||
|
|
||||||
|
为了使问题更清晰,我想先解释一下映射超时。映射超时经常在模糊映射时发生:
|
||||||
|
|
||||||
|
```vim
|
||||||
|
:nnoremap ,a :echo 'foo'<cr>
|
||||||
|
:nnoremap ,ab :echo 'bar'<cr>
|
||||||
|
```
|
||||||
|
|
||||||
|
两个映射都有可能,键入 `,a` ,就会有一秒钟的延迟,因为 Vim 会等待用户会再键入 `b` 还是不会了。
|
||||||
|
|
||||||
|
退出序列也会引起一样的问题:
|
||||||
|
|
||||||
|
- `<esc>` 在返回正常模式或退出指令时被大量使用。
|
||||||
|
- 光标键使用了退出序列进行编码
|
||||||
|
- Vim 运用 <kbd>Alt</kbd> (也被称为 _Meta key_)去发送固定的高位集编码的8位比特,但是很多终端虚拟器不支持(或者默认不启用),而用退出序列代替。
|
||||||
|
|
||||||
|
你可以用 `vim -u NONE -N` 试一试上面所说的,然后键入 `i<c-v><left>` ,你就会看见一串以 `^[`(表征退出码)开头的被输入序列。
|
||||||
|
|
||||||
|
简而言之,区分键入的 `<esc>` 和一个严格意义上的退出序列对 Vim 来说是一个痛苦的过程。
|
||||||
|
|
||||||
|
默认情况下 `:set timeout timeoutlen=1000` ,Vim 会有1秒的延迟在等 _还有吗_ 的模糊映射。
|
||||||
|
对于映射来说,这是一个稳健的值,但是通常为了解决整个问题,你可以自定义键入的超时阈值:
|
||||||
|
|
||||||
|
```vim
|
||||||
|
set timeout " 映射超时
|
||||||
|
set timeoutlen=1000 " 默认值
|
||||||
|
set ttimeout " 键入超时
|
||||||
|
set ttimeoutlen=10 " 察觉不到的小值
|
||||||
|
```
|
||||||
|
|
||||||
|
执行 `:h ttimeout` 你可以找到一个小表格展示这些选项的相互关系。
|
||||||
|
|
||||||
|
如果你在 Vim 和终端虚拟器之间使用的是 tmux ,请将以下一行放入 `~/.tmux.conf`:
|
||||||
|
|
||||||
|
```tmux
|
||||||
|
set -sg escape-time 0
|
||||||
|
```
|
13
chapter/easter-eggs.md
Normal file
13
chapter/easter-eggs.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
## 复活节彩蛋
|
||||||
|
|
||||||
|
| 命令 | 消息 |
|
||||||
|
|-----------|---------|
|
||||||
|
| `:Ni!` | `你需要灌木丛?` |
|
||||||
|
| `:h 'sm'` | `注意:这个缩写是限制级` |
|
||||||
|
| `:h 42` | `生命,宇宙和一切的意义是什么?不幸的是, 道格拉斯·亚当斯(Douglas Adams),唯一知道这个问题的人现在已经死了。所以现在你可能会想知道死亡的意思是什么……` |
|
||||||
|
| `:h UserGettingBored` | `什么时候用户会按同一个键42次?好吧,我只是开个玩笑 :-)` |
|
||||||
|
| `:h bar` | `这不是一个烟斗。` |
|
||||||
|
| `:h holy-grail` | `亚瑟,你终究找到了!` |
|
||||||
|
| `:h map-modes` | `:nunmap 命令在修道院外也能用.` |
|
||||||
|
| `:help!` | `E478:别怕!` (故障? 在使用模块帮助时 (`模块类型=帮助`) 这和 `:h help.txt` 一个效果。) |
|
||||||
|
| `:smile` | `试一试这个表情 ;-) 添加于 7.4.1005.` |
|
@ -1,20 +1,20 @@
|
|||||||
## 编辑大文件很慢
|
## 编辑大文件很慢
|
||||||
|
|
||||||
大文件最大的问题,就是 Vim 会一次性读取整个文件。这一过程的完成取决于内部如何提供缓存空间。
|
大文件最大的问题,就是 Vim 会一次性读取整个文件。这一过程的完成取决于内部如何提供缓存空间。
|
||||||
([Vim 开发的讨论](https://groups.google.com/forum/#!topic/vim_dev/oY3i8rqYGD4/discussion))
|
([Vim 开发的讨论](https://groups.google.com/forum/#!topic/vim_dev/oY3i8rqYGD4/discussion))
|
||||||
|
|
||||||
如果你只是想读取, `tail hugefile | vim -` 会是一个很好的解决方法.
|
如果你只是想读取, `tail hugefile | vim -` 会是一个很好的解决方法.
|
||||||
|
|
||||||
如果不用语法,设定和插件,你也能生活自理一段时间:
|
如果不用语法,设定和插件,你也能生活自理一段时间:
|
||||||
|
|
||||||
```
|
```
|
||||||
$ vim -u NONE -N
|
$ vim -u NONE -N
|
||||||
```
|
```
|
||||||
|
|
||||||
这将使得导航明显提速,因为代价高昂的语法高亮正则表达式不再被使用。你也应该让 Vim 不要使用交换文件和 Vim 信息文件,以避免写入时的长延迟。
|
这将使得导航明显提速,因为代价高昂的语法高亮正则表达式不再被使用。你也应该让 Vim 不要使用交换文件和 Vim 信息文件,以避免写入时的长延迟。
|
||||||
|
|
||||||
```
|
```
|
||||||
$ vim -n -u NONE -i NONE -N
|
$ vim -n -u NONE -i NONE -N
|
||||||
```
|
```
|
||||||
|
|
||||||
简而言之,真的写入超大文件的时候尽量别用 Vim。 :\
|
简而言之,真的写入超大文件的时候尽量别用 Vim。 :\
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
## 无法重复函数中执行的搜索
|
## 无法重复函数中执行的搜索
|
||||||
|
|
||||||
- 一个命令的搜索关键词(`/`, `:代替`, ...)改变了“上一次搜索所用的关键词”。(这个改变保存在 `/` 的注册表里;使用 `:echo @/` 可以打印出来)
|
- 一个命令的搜索关键词(`/`, `:代替`, ...)改变了“上一次搜索所用的关键词”。(这个改变保存在 `/` 的注册表里;使用 `:echo @/` 可以打印出来)
|
||||||
- 一个简单的文本修改可以用 `.` 再次执行。(这个执行保存在 `.` 的注册表里;使用 `:echo @.` 可以打印出来)
|
- 一个简单的文本修改可以用 `.` 再次执行。(这个执行保存在 `.` 的注册表里;使用 `:echo @.` 可以打印出来)
|
||||||
|
|
||||||
如果你在一个函数里做以上操作,两件都_not_会是那么回事儿。所以你不能简单地在一个函数里高亮词汇同时再用这个函数做文本修改。
|
如果你在一个函数里做以上操作,两件都_not_会是那么回事儿。所以你不能简单地在一个函数里高亮词汇同时再用这个函数做文本修改。
|
||||||
|
|
||||||
帮助: `:h function-search-undo`
|
帮助: `:h function-search-undo`
|
@ -1,30 +1,30 @@
|
|||||||
## 映射大写锁定键(CapsLock)到控制键(Ctrl)
|
## 映射大写锁定键(CapsLock)到控制键(Ctrl)
|
||||||
|
|
||||||
大写锁定键属于键盘上最少用到的按键,但是它要比控制键更加容易按到,
|
大写锁定键属于键盘上最少用到的按键,但是它要比控制键更加容易按到,
|
||||||
因为它位于你手放在键盘时的[起始行](https://raw.githubusercontent.com/mhinz/vim-galore/master/contents/images/content-homerow.png)。
|
因为它位于你手放在键盘时的[起始行](https://raw.githubusercontent.com/mhinz/vim-galore/master/contents/images/content-homerow.png)。
|
||||||
如果你敲很多代码的话,映射大写锁定键(CapsLock)到控制键(Ctrl)可以有效降低
|
如果你敲很多代码的话,映射大写锁定键(CapsLock)到控制键(Ctrl)可以有效降低
|
||||||
[重复使力伤害](https://de.wikipedia.org/wiki/Repetitive-Strain-Injury-Syndrom) (ps:为什么将 jk 映射为 esc,而不是 jj,重复点击同一个按键对手指伤害很大)。
|
[重复使力伤害](https://de.wikipedia.org/wiki/Repetitive-Strain-Injury-Syndrom) (ps:为什么将 jk 映射为 esc,而不是 jj,重复点击同一个按键对手指伤害很大)。
|
||||||
|
|
||||||
友情提示:当你习惯这个设定后,你就离不开它了。
|
友情提示:当你习惯这个设定后,你就离不开它了。
|
||||||
|
|
||||||
**OSX**:
|
**OSX**:
|
||||||
|
|
||||||
`System Preferences -> Keyboard -> Keyboard Tab -> Modifier Keys`. 变更
|
`System Preferences -> Keyboard -> Keyboard Tab -> Modifier Keys`. 变更
|
||||||
"CapsLock" 为 "Control"。
|
"CapsLock" 为 "Control"。
|
||||||
|
|
||||||
**Linux**:
|
**Linux**:
|
||||||
|
|
||||||
为了使按键生效,请把以下几行放入 `~/.xmodmap` 文件:
|
为了使按键生效,请把以下几行放入 `~/.xmodmap` 文件:
|
||||||
|
|
||||||
remove Lock = Caps_Lock
|
remove Lock = Caps_Lock
|
||||||
keysym Caps_Lock = Control_L
|
keysym Caps_Lock = Control_L
|
||||||
add Control = Control_L
|
add Control = Control_L
|
||||||
|
|
||||||
用以下命令使之生效<br> `$ xmodmap ~/.xmodmap`。
|
用以下命令使之生效<br> `$ xmodmap ~/.xmodmap`。
|
||||||
|
|
||||||
替代方法有[caps2esc](https://github.com/oblitum/caps2esc) 或者
|
替代方法有[caps2esc](https://github.com/oblitum/caps2esc) 或者
|
||||||
[xcape](https://github.com/alols/xcape)。
|
[xcape](https://github.com/alols/xcape)。
|
||||||
|
|
||||||
**Windows**:
|
**Windows**:
|
||||||
|
|
||||||
请参看 [superuser.com: 在Windows8.1映射大写锁定键到控制键](http://superuser.com/questions/764782/map-caps-lock-to-control-in-windows-8-1)。
|
请参看 [superuser.com: 在Windows8.1映射大写锁定键到控制键](http://superuser.com/questions/764782/map-caps-lock-to-control-in-windows-8-1)。
|
||||||
|
5
chapter/newline-used-for-nul.md
Normal file
5
chapter/newline-used-for-nul.md
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
## NUL 符用新行表示
|
||||||
|
|
||||||
|
文件中的 NUL 符 (`\0`),在内存中被以新行(`\n`)保存,在缓存空间中显示为 `^@`。
|
||||||
|
|
||||||
|
更多信息请参看 `man 7 ascii` 和 `:h NL-used-for-Nul` 。
|
@ -1,11 +1,11 @@
|
|||||||
## 内置插件
|
## 内置插件
|
||||||
|
|
||||||
出乎很多人的意料,Vim自己默认加载了大把大把的插件。启动 Vim 后,用`:scriptnames`查看所有加载的源文件
|
出乎很多人的意料,Vim自己默认加载了大把大把的插件。启动 Vim 后,用`:scriptnames`查看所有加载的源文件
|
||||||
|
|
||||||
这些文件多数永远不会被用到,所以请禁止如你所见的以下插件。
|
这些文件多数永远不会被用到,所以请禁止如你所见的以下插件。
|
||||||
这些插件仍旧会在源文件列出,但是当Vim启动时,只有第一行会被读取,而之后的配置,命令和日志都不会执行。
|
这些插件仍旧会在源文件列出,但是当Vim启动时,只有第一行会被读取,而之后的配置,命令和日志都不会执行。
|
||||||
|
|
||||||
| 插件 | 禁用 | 帮助 |
|
| 插件 | 禁用 | 帮助 |
|
||||||
|------------|-------------------------------------|------|
|
|------------|-------------------------------------|------|
|
||||||
| 2html | `let g:loaded_2html_plugin = 1` | `:h 2html` |
|
| 2html | `let g:loaded_2html_plugin = 1` | `:h 2html` |
|
||||||
| getscript | `let g:loaded_getscriptPlugin = 1` | `:h pi_getscript` |
|
| getscript | `let g:loaded_getscriptPlugin = 1` | `:h pi_getscript` |
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
## Vim 配置集合
|
## Vim 配置集合
|
||||||
|
|
||||||
Vim 配置集合是集成多多种插件以及相关配置的组合。
|
Vim 配置集合是集成多多种插件以及相关配置的组合。
|
||||||
|
|
||||||
高阶用户总是知道如何构建自己的编辑器,所以配置集合一般是针对初学者。
|
高阶用户总是知道如何构建自己的编辑器,所以配置集合一般是针对初学者。
|
||||||
如果你想要尝试,那么将面临一个辩证的想法:加入很多额外的东西来学习 Vim 是否会让这变得更加简单。
|
如果你想要尝试,那么将面临一个辩证的想法:加入很多额外的东西来学习 Vim 是否会让这变得更加简单。
|
||||||
|
|
||||||
我知道很多人不想在配置编辑器上花过多时间(但实际上,当你卡住时,你就会不停地花时间定制自己的 vimrc)
|
我知道很多人不想在配置编辑器上花过多时间(但实际上,当你卡住时,你就会不停地花时间定制自己的 vimrc)
|
||||||
因此,想要节约时间,那么就因该真正的去了解和学习 Vim 原生功能,只有这样你才能中获益。
|
因此,想要节约时间,那么就因该真正的去了解和学习 Vim 原生功能,只有这样你才能中获益。
|
||||||
|
|
||||||
再次强调一下:“一个程序员应当懂得他的工具”。
|
再次强调一下:“一个程序员应当懂得他的工具”。
|
||||||
|
|
||||||
总之,如果你知道自己在做什么,你也许能从以下几个 Vim 配置集合中获得一些灵感。
|
总之,如果你知道自己在做什么,你也许能从以下几个 Vim 配置集合中获得一些灵感。
|
||||||
|
|
||||||
- [cream](http://cream.sourceforge.net)
|
- [cream](http://cream.sourceforge.net)
|
||||||
- [janus](https://github.com/carlhuda/janus.git)
|
- [janus](https://github.com/carlhuda/janus.git)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
## 为什么用hjkl移动光标?
|
## 为什么用hjkl移动光标?
|
||||||
|
|
||||||
当 [Bill Joy](https://en.wikipedia.org/wiki/Bill_Joy) 创建[vi](https://en.wikipedia.org/wiki/Vi),Vim 的前身时, 他的工作是在一台[ADM-3A](https://en.wikipedia.org/wiki/ADM-3A)完成的,而这个机器没有用别的键控制光标,而正是如你猜到的 hjkl 作为光标控制键。
|
当 [Bill Joy](https://en.wikipedia.org/wiki/Bill_Joy) 创建[vi](https://en.wikipedia.org/wiki/Vi),Vim 的前身时, 他的工作是在一台[ADM-3A](https://en.wikipedia.org/wiki/ADM-3A)完成的,而这个机器没有用别的键控制光标,而正是如你猜到的 hjkl 作为光标控制键。
|
||||||
|
|
||||||
键盘布局: [请点击](https://raw.githubusercontent.com/mhinz/vim-galore/master/contents/images/content-adm-3a-layout.jpg)
|
键盘布局: [请点击](https://raw.githubusercontent.com/mhinz/vim-galore/master/contents/images/content-adm-3a-layout.jpg)
|
||||||
|
|
||||||
这也告诉了我们为什么 Unix 系统会以`~`代表主目录。
|
这也告诉了我们为什么 Unix 系统会以`~`代表主目录。
|
||||||
|
|
||||||
|
@ -53,11 +53,11 @@ endif
|
|||||||
" Put all temporary files under the same directory.
|
" Put all temporary files under the same directory.
|
||||||
" https://github.com/mhinz/vim-galore#handling-backup-swap-undo-and-viminfo-files
|
" https://github.com/mhinz/vim-galore#handling-backup-swap-undo-and-viminfo-files
|
||||||
set backup
|
set backup
|
||||||
set backupdir =$HOME/.vim/files/backup//
|
set backupdir =$HOME/.vim/files/backup/
|
||||||
set backupext =-vimbackup
|
set backupext =-vimbackup
|
||||||
set backupskip =
|
set backupskip =
|
||||||
set directory =$HOME/.vim/files/swap//
|
set directory =$HOME/.vim/files/swap//
|
||||||
set updatecount =100
|
set updatecount =100
|
||||||
set undofile
|
set undofile
|
||||||
set undodir =$HOME/.vim/files/undo//
|
set undodir =$HOME/.vim/files/undo/
|
||||||
set viminfo ='100,n$HOME/.vim/files/info/viminfo
|
set viminfo ='100,n$HOME/.vim/files/info/viminfo
|
||||||
|
3
create-syntax-file.md
Normal file
3
create-syntax-file.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# Vim 语法高亮
|
||||||
|
|
||||||
|
前面,我们提到可以通过 `syntax on` 启用语法高亮,那么 Vim 是根据什么来判定当前文件所需要使用的语法高亮的呢
|
Loading…
x
Reference in New Issue
Block a user