Bash的vim模式,而不是vi

编程入门 行业动态 更新时间:2024-10-12 12:29:30
本文介绍了Bash的vim模式,而不是vi的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当我发现类似vi的bash的编辑模式时,我着迷了.可以通过发出 set -o vi 命令轻松地切换它.但是有什么方法可以切换类似vim的模式吗?

I was fascinated when I discovered vi-like bash's editing mode. One can easily toggle it by issuing set -o vi command. But is there any way to toggle vim-like mode?

我的意思是,当您处于类似vi的模式时,可以按 v 键并在功能齐全的vi编辑器窗口中编辑命令,但是我想知道如何强制bash启动< vim 编辑器而不是 vi ,因为 vim 为我们提供了额外的好处(可视化选择,其他命令等)?

I mean when you are in a vi-like mode you can press v key and edit your commands in a fully functional vi editor's window but I would like to know how to force bash to start vim editor instead of vi because of the perks vim provides us (visual selection, additional commands etc)?

推荐答案

如果设置了 EDITOR 变量,则在bash中,您可以按 Ctrl-x ctrl-e 进行编辑您当前的 EDITOR 中的命令行,例如 vim

If you set EDITOR variable, in bash you can press Ctrl-x ctrl-e to edit your current command line in your EDITOR e.g. vim

ctrl-x ctrl-e 用于emacs模式的命令行编辑,这是默认设置.如果已经将其设置为vi模式,则可以按 v 进行操作.如果要在vim中打开cmd行,则必须设置 EDITOR 变量(例如,在.bashrc中)

the ctrl-x ctrl-e is for emacs mode commandline editing, which is the default one. If you have already set it to vi mode, you could do what you have said, pressing the v. If you want to open the cmd line in vim, you have to set the EDITOR variable (in your .bashrc for example)

我个人以emacs模式编辑命令行,即使vim是我的主要(也是唯一)编辑器.

Personally I edit command line in emacs mode, even though vim is my main (and only) editor.

更多推荐

Bash的vim模式,而不是vi

本文发布于:2023-10-09 05:35:35,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1474850.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:而不是   模式   Bash   vim   vi

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!