[英]OS X Terminal shortcut: Jump to beginning/end of line
I know that I can jump to the beginning and end of a line inside the OS X terminal with Ctrl + A and Ctrl + E .我知道我可以使用Ctrl + A和Ctrl + E跳转到 OS X 终端内一行的开头和结尾。 But I'm so used to jumping with Cmd + Right arrow and Cmd + Left arrow from my editor, that I would love to use these shortcuts for the terminal too.
但是我已经习惯了使用编辑器中的Cmd +右箭头和Cmd +左箭头进行跳转,因此我也很想在终端上使用这些快捷方式。
I haven't found a solution with Google, so maybe here someone can help.我还没有找到谷歌的解决方案,所以也许有人可以提供帮助。
Update更新
As in the comments, I tried the solution from How to move the cursor word by word in the OS X Terminal如评论中所述,我尝试了如何在 OS X 终端中逐字移动光标的解决方案
Unfortunately, the Terminal settings seems to not include Cmd as a Modifier Key, as you can see here:不幸的是,终端设置似乎不包括Cmd作为修饰键,如您在此处看到的:
fn + shift + leftArrow = goto beginning of line
fn + shift + rightArrow = goto end of line
these work for me这些对我有用
在最新的 Mac OS 中您可以使用shift
+ home
或shift
+ end
I use a handy app called Karabiner to do this, and many other things.我使用一个名为Karabiner的便捷应用程序来执行此操作以及许多其他操作。 It's free and open source.
它是免费和开源的。
It's a keyboard remapper, with a lot of handy presets for many common remaps that people may want to do.它是一个键盘重映射器,为人们可能想要做的许多常见重映射提供了许多方便的预设。
As you can see from the screenshot, this remap is included as a preset in Karabiner.正如您从屏幕截图中看到的那样,此重映射作为预设包含在 Karabiner 中。
Hope this helps.希望这可以帮助。 Happy remapping!
快乐重新映射!
As setup in the terminal using vi
:在终端中使用
vi
进行设置:
The Home
button on a Macbook Pro keyboard: Fn + Left Arrow
. Macbook Pro 键盘上的
Home
按钮: Fn + Left Arrow
。
The End
button on a Macbook Pro keyboard: Fn + Right Arrow
. Macbook Pro 键盘上的
End
按钮: Fn + Right Arrow
。
Here I found a tweak for this, without any third party tool .在这里我找到了一个调整,没有任何第三方工具。 This will make the following shortcut to work:
这将使以下快捷方式起作用:
fn + right: to go to the end of the line.
fn + left: to go to the beginning of the line.
cmd + ,
).cmd + ,
)。 That's all.就这样。 Now close and check.
现在关闭并检查。
Hope it helps.希望能帮助到你。
EDIT: Refer to the comment by @Maurice Gilden below for more insights.编辑:有关更多见解,请参阅下面@Maurice Gilden 的评论。
Control + A转到开头, Control + E转到结尾
For iterm2:对于 iterm2:
Go to Profiles / Open Profiles / Keys转到配置文件/打开配置文件/密钥
Set Cmd + left_arrow_key
to Send Hex Code 001
设置
Cmd + left_arrow_key
发送Hex Code 001
Set Cmd + right_arrow_key
to Send Hex Code 005
设置
Cmd + right_arrow_key
发送Hex Code 005
This allows you to use Cmd + arrow_keys
to move from beginning to end of the line.这允许您使用
Cmd + arrow_keys
从行首移动到行尾。
I am not sure if this will work for you (I still use OS 10.8
), but these work for my terminal:我不确定这是否适合您(我仍然使用
OS 10.8
),但这些适用于我的终端:
home = move cursor to the start of the line
shift+end = move cursor to the end of the line
alt+leftArrow = move one "word" to the left
alt+rightArrow = move one "word" to the right
Hope this helps!希望这可以帮助!
For latest mac os, Below shortcuts works for me.对于最新的 mac os,下面的快捷方式对我有用。
Jump to beginning of the line == shift + fn + RightArrow跳转到行首 == shift + fn + RightArrow
Jump to ending of the line == shift + fn + LeftArrow跳转到行尾 == shift + fn + LeftArrow
fn + leftArraw or fn + rightArrow
为我工作!
You could download Better Touch Tools .您可以下载Better Touch Tools 。 It's an app that allows you to make custom key-bindings and shortcuts over your entire system or individual apps.
这是一个应用程序,可让您在整个系统或单个应用程序上进行自定义键绑定和快捷方式。 Using it, you could make a shortcut in the terminal that emulates ctrl-a/ctrl-e whenever you press cmd-left/cmd-right, respectively.
使用它,您可以在终端中创建一个快捷方式,在您分别按下 cmd-left/cmd-right 时模拟 ctrl-a/ctrl-e。 I definitely recommend it!
我绝对推荐它! I've been using it for years and I have over 50 shortcuts spread across several different apps.
我已经使用它多年了,我有超过 50 个快捷方式分布在几个不同的应用程序中。
Text Navigation Shortcuts文本导航快捷方式
Command+Left Arrow
Command+Left Arrow
Command+Right Arrow
Command+Right Arrow
Option+Left Arrow
Option+Left Arrow
Option+Right Arrow
Option+Right Arrow
Command+Up Arrow
Command+Up Arrow
Command+Down Arrow
Command+Down Arrow
Text Selection Shortcuts文本选择快捷键
Select text to beginning of a line – Shift+Command+Left Arrow
选择文本到行首 –
Shift+Command+Left Arrow
Select text to end of a line – Shift+Command+Right Arrow
选择文本到行尾 –
Shift+Command+Right Arrow
Select text to beginning of current word – Shift+Option+Left Arrow
选择文本到当前单词的开头 -
Shift+Option+Left Arrow
Select text to end of current word – Shift+Option+Right Arrow
选择文本到当前单词的结尾 -
Shift+Option+Right Arrow
Select text to beginning of all text – Shift+Command+Up Arrow
选择文本到所有文本的开头 –
Shift+Command+Up Arrow
Select text to end of all text – Shift+Command+Down Arrow
选择文本到所有文本的结尾 –
Shift+Command+Down Arrow
in iterm2在 iterm2
fn + leftArraw or fn + rightArrow
fn + leftArraw 或 fn + rightArrow
this worked for me这对我有用
This worked for me Option + left-arrow
or Option + right-arrow
for moving the cursor to the start or end of the line.这对我
Option + left-arrow
或Option + right-arrow
,用于将光标移动到行的开头或结尾。
Mac Os Version : Catalina Mac OS 版本:Catalina
As per the official website of Apple根据苹果官方网站
control + A - Move to the beginning of the line
control + E - move to the end of the line
terminal shortcuts by Apple's official site Apple 官方网站的终端快捷方式
i have the same issue on MacOS 12 (Monterey) - want to go to beginning and end of the line with fn + arrow keys.我在 MacOS 12 (Monterey) 上遇到了同样的问题 - 想用 fn + 箭头键转到行的开头和结尾。 When you are trying to write '\' in that text field, it becomes '\\' (with escape).
当您尝试在该文本字段中写入“\”时,它会变为“\\”(带有转义)。 You need to paste this text (copy from some text editor, o from terminal) \001 (home) and \005 (end) in field.
您需要在字段中粘贴此文本(从某些文本编辑器复制,o 从终端)\001(主页)和 \005(结束)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.