May 19

vim自动格式化的功能 不指定

bkkkd , 17:27 , 开发应用 , 评论(1) , 引用(0) , 阅读(15286) , Via 本站原创 | |
真没想到Vim确实很强大,强大到自己就有自动格式化的功能.而且比其它的编辑器的自动格式化还要强大.

我在网上搜索了 Vim 代码格式化 找出来的内容大都是下面这篇文件

引用

从别的编辑器里粘贴到vim里的代码经常由于不正常的缩进变得格式混乱。

格式化全文: gg=G

自动缩进当前行: ==

格式化当前光标接下来的10行: 10=

格式化选定的行: v   (向上下选择)=

官方解释:http://vimdoc.sourceforge.net/cgi-bin/vimfaq2html3.pl#14.6

14.6.

How do I format/indent an entire file?

You can format/indent an entire file using the gg=G command, where

    gg - Goto the beginning of the file

    =  - apply indentation

    G  - till end of file

For more information, read

    :help gg

    :help =

    :help G

    :help 'formatprg'


    :help C-indenting

但这里没有说明具体怎么使用
我在这里就说明一下,在需要普通模式下输入

gg

这个命令会使用光标移动到文件开头

然后再输入
[code]
=G

将文件格式化.
其中 =G是组合命令.=号是格式化的命令,而G是指定范围到文件末端.
123
June 6, 2018 15:29
bkkkd 回复于 July 20, 2018 08:46
怎么渣了?
分页: 1/1 第一页 1 最后页
发表评论
表情
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
emotemotemotemotemot
打开HTML
打开UBB
打开表情
隐藏
记住我
昵称   密码   游客无需密码
网址   电邮   [注册]