在 VIM 中选择整行,不带换行符 [英] Select entire line in VIM, without the new line character

查看:68
本文介绍了在 VIM 中选择整行,不带换行符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 VIM 中选择没有换行符的整行的最短方法是什么?

Which is the shortest way to select an entire line without the new line character in VIM?

我知道 SHIFT + v 选择整行,但带有换行符.

I know that SHIFT + v selects the entire line, but with new line character.

为此,我转到线路并按:

To do this I go to the line and I press:

  • ^(将光标放在行首)
  • v(开始视觉选择)
  • $(选择包括换行符在内的整行)
  • (取消选择换行符)
  • ^ (puts the cursor at the start of the line)
  • v (starts the visual select)
  • $ (selects the entire line including new line character)
  • Left (unselects the new line character)

我也知道我可以创建一个录音来做这样的事情.但我在问是否有任何内置的快捷方式...

I also know that I can create a recording that does such a thing. But I am asking if is there any built-in shortcuts...

推荐答案

不,没有任何内置的东西可以完成这项工作.这就是为什么人们甚至创建了插件来满足需求.

No, there is nothing built-in that does the job. That's why people have even created plugins to address the need.

可能最受欢迎的选择是textobj-line.使用 textobj-line 可以获得两个新的文本对象,al一行"和 il内行".那么,

Probably the most popular choice is textobj-line. With textobj-line you get two new text objects, al "a line" and il "inner line". Then,

  • vil 选择该行的可打印内容(如 ^vg_),
  • val 选择整行内容(如 0v$h).
  • vil selects the printable contents of the line (like ^vg_),
  • val selects the entire line contents (like 0v$h).

两者都不在选择中包含换行符.

Both do not include the newline in the selection.

如果你问我的话,非常方便的插件.它也适用于运算符.

Pretty handy plugin if you ask me. And it works with operators, too.

根据要求,安装:

  • 使用普通的 Vim:
  • With plain Vim:
  1. 获取最新的textobj-user并提取其目录进入~/.vim.
  2. 获取最新的textobj-line并提取其目录进入~/.vim.
  3. 生成帮助标签:helptags ~/.vim/doc.

  • 使用插件管理器(推荐):只需按照插件管理器的常规安装过程进行操作,同时不要忘记安装 textobj-user 依赖项.
  • 这篇关于在 VIM 中选择整行,不带换行符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆