vim a.vim如何使用_Vim用不同的方式上线

vim a.vim如何使用

vim a.vim如何使用

Vim provides a lot of useful features and shortcuts during usage. In this tutorial we will look different ways to go specified line numbers or position in a file.

Vim在使用过程中提供了许多有用的功能和快捷方式。 在本教程中,我们将寻找在文件中指定行号或位置的不同方法。

显示行号 (Show Line Numbers)

In this tutorial we will learn navigating to the specified line in vim. But how can we specify line we want to go. We need line numbers. We are sure that counting line numbers one by one is not a good way especially in big files. So We need to show line numbers in vim. We can use : set number like below.

在本教程中,我们将学习导航到vim中的指定行。 但是我们如何指定要走的线。 我们需要行号。 我们确信,逐行计数行号不是一个好方法,尤其是在大文件中。 因此,我们需要在vim中显示行号。 我们可以使用: set number如下。

: set number
Show Line Numbers
Show Line Numbers
显示行号

转到命令行(Go To Line with Command Line)

Now most crucial part we will see different ways to go specified line. The simplest one is specifying line number as a vim command with :. In this example we will navigate to the 30 with the following command.

现在最关键的部分,我们将看到前往指定行的不同方法。 最简单的一个是指定的行号与一个VIM命令: 。 在此示例中,我们将使用以下命令导航到30

: 30

转到捷径 (Go To Line with Shortcut)

We can go to the specified line whiteout using command line. We will use shortcut for this operation. In this example we will go to the line 20.

我们可以使用命令行转到指定的行中断。 我们将使用快捷方式执行此操作。 在此示例中,我们将转到第20行。

20G

打开文件后转到行 (Go To Line After Opening File)

If we know the line number all ready before opening the file we can specify the line number as a parameter. We will go line number 45 after opening the file with the following command.

如果在打开文件之前知道行号已准备就绪,则可以将行号指定为参数。 使用以下命令打开文件后,我们将转到第45行。

$ vim +45 main.c

文件结束 (End Of File)

We can also simply go to the end of line without specifically providing the end line number. We can use G command like below.

我们也可以简单地转到行尾,而无需特别提供结束行号。 我们可以使用如下的G命令。

G

文件开始 (Start Of File)

There is different alternatives to go first line . Because know know the first line number we can simply say go line number 1. or other alternatives.

第一线有不同的选择。 因为知道知道第一行号,所以我们可以简单地说行号1.或其他选择。

LEARN MORE  Ultimate Sed Tutorial With Examples
了解更多带示例的Ultimate Sed教程

用行号转到第一行(Go First Line with Line Number)

:1

转到第一行键盘快捷键 (Go First Line Keyboard shortcut)

gg

翻译自: https://www.poftut.com/vim-go-line-different-ways/

vim a.vim如何使用

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值