Ama*_*9MF 42

的!限定符告诉Vim强制操作.例如,如果文件是只读的,您将使用:w!无论如何写它.如果文件已被修改并且您想要在不保存的情况下退出,则可以使用:q!.:WQ!只是意味着在一个命令中强制写入和退出.

  • @janoChen,是的,你会习惯`Ctrl-S`而不会练习`:w!`够:) (2认同)

Eug*_*ash 32

感叹号通常意味着强制采取一些行动.

散文标记的另一种用法:!后跟一些命令直接从编辑器执行此命令.

__PRE__


小智 29

除了感叹号强制事物(如写入)的情况之外,它还会将命令转换为切换命令.所以,如果我这样做:

:set cursorline
Run Code Online (Sandbox Code Playgroud)

我的光标所在的行将突出显示.我可以用以下方式关闭它:

:set nocursorline
Run Code Online (Sandbox Code Playgroud)

或者我可以这样做:

:set cursorline!
Run Code Online (Sandbox Code Playgroud)

该命令在两个设置之间翻转,关闭和打开.

我经常关闭和打开光标线高亮显示,并且toggle命令允许我使用简单的功能键映射.没有切换,我需要两个映射:一个打开它,另一个打开它.或者我必须编写一个函数来确定光标线设置是打开还是关闭,然后打开相反的设置.

据我所知,这适用于所有具有开启和关闭设置的命令行设置,如hlsearch,paste,cursorcolumn,number,insearch等.

另请注意,感叹号将切换命令的版本.例如,您还可以使用以下方法切换光标线设置:

:set nocursorline!
Run Code Online (Sandbox Code Playgroud)


Luc*_*tte 9

这实际上取决于所考虑的命令.关于你所列举的那些,它强制命令,因为其他人已经回答你.

不过,也有像其他命令:global,:map,:make,:silent,...,那里的爆炸(!)还有其他的作用.阅读他们的文件:

:help help
Run Code Online (Sandbox Code Playgroud)

(我们可以在我们定义的命令中给出我们想要的任何意义)


Goo*_*Pen 8

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\n\n\n\n\n
例子意义
:wq! :q!无论如何都要做!
:autocmd! {group} {event} {pat} cmd覆盖特定的自动命令 ( :help autocmd-remove*)
:function!覆盖现有的
:com[mand][!] [{attr}...] {cmd} {repl}覆盖现有的
:set number!(用 1\xef\xbc\x8c 或 1 \xe2\x86\x92 0 覆盖 0)切换选项
:!ls外壳命令
\n
\n
:com[mand][!] [{attr}...] {cmd} {repl}\n                        Define a user command.  The name of the command is\n                        {cmd} and its replacement text is {repl}.  The\n                        command\'s attributes (see below) are {attr}.  If the\n                        command already exists, an error is reported, unless a\n                        ! is specified, in which case the command is\n\n
Run Code Online (Sandbox Code Playgroud)\n
Command attributes\n\nUser-defined commands are treated by Vim just like any other Ex commands.  They\ncan have arguments, or have a range specified.  Arguments are subject to\ncompletion as filenames, buffers, etc.  Exactly how this works depends upon the\ncommand\'s attributes, which are specified when the command is defined.\n\nThere are a number of attributes, split into four categories: argument\nhandling, completion behavior, range handling, and special cases.  The\nattributes are described below, by category.\n
Run Code Online (Sandbox Code Playgroud)\n

......

\n
Special cases\n                                        :command-bang :command-bar\n                                        :command-register :command-buffer\n                                        :command-keepscript\nThere are some special cases as well:\n\n        -bang       The command can take a ! modifier (like :q or :w)\n        -bar        The command can be followed by a "|" and another command.\n                    A "|" inside the command argument is not allowed then.\n                    Also checks for a " to start a comment.\n
Run Code Online (Sandbox Code Playgroud)\n

\n
\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
例子意义
#!/bin/sh杀帮
!!最后的历史
!2倒数第二个历史
\n

ipython 和 ptipython

\n
\n\n\n\n\n\n\n\n\n\n\n\n\n\n
例子意义
:!ls外壳命令
\n