Visual studio code 如何突出显示用于在VS代码终端中复制和粘贴的文本?
如何创建快捷键以突出显示终端文本:Ctrl+Shift+Right/Left、Ctrl+Shift+End、Ctrl+Shift+Home-正如在PowerShell ISE中实现的那样Visual studio code 如何突出显示用于在VS代码终端中复制和粘贴的文本?,visual-studio-code,terminal,Visual Studio Code,Terminal,如何创建快捷键以突出显示终端文本:Ctrl+Shift+Right/Left、Ctrl+Shift+End、Ctrl+Shift+Home-正如在PowerShell ISE中实现的那样 如何创建按单词移动光标的快捷方式:Ctrl+Right/Left,类似于PowerShell ISE?我说您想使用Ctrl+Left/Right按单词的开头和结尾导航光标,对吗 转到键盘设置:代码>首选项>键盘快捷键 搜索: cursorWordEndRight和绑定到Ctrl+Right将允许您移动到单词末尾
如何创建按单词移动光标的快捷方式:Ctrl+Right/Left,类似于PowerShell ISE?我说您想使用Ctrl+Left/Right按单词的开头和结尾导航光标,对吗 转到键盘设置:代码>首选项>键盘快捷键 搜索:
cursorWordEndRight
和绑定到Ctrl+Right
将允许您移动到单词末尾
cursorwordstarteft
bind toCtrl+Left
将允许您移动到单词的开头
您也可以选择以下选项:
cursorwordstarteftselect
并绑定到Ctrl+Shift+Left
cursorWordEndRightSelect
并绑定到Ctrl+Shift+Right
您的keybindings.json
应该如下所示:
// Place your key bindings in this file to override the defaults
[
{
"key": "ctrl+right",
"command": "cursorWordEndRight",
"when": "textInputFocus"
},
{
"key": "ctrl+left",
"command": "cursorWordStartLeft",
"when": "textInputFocus"
},
{
"key": "shift+ctrl+left",
"command": "cursorWordStartLeftSelect",
"when": "textInputFocus"
},
{
"key": "shift+ctrl+right",
"command": "cursorWordEndRightSelect",
"when": "textInputFocus"
}
]
您可能希望查看此链接以获取在vscode中重新绑定快捷键的参考
及
希望这有帮助:)我为愿意安装zsh的用户添加了一个单独的答案 这是一个不做任何假设的局部解决方案:
{
"key": "ctrl+left",
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "\u001bb" },
"when": "terminalFocus"
},
{
"key": "ctrl+right",
"command": "workbench.action.terminal.sendSequence",
"args": { "text": "\u001bf" },
"when": "terminalFocus"
}
它将为您提供Windows样式的Ctrl左/右导航
这会出现在keybindings.json中。我的地址是~\AppData\Roaming\code\User\keybindings.json
和~\AppData\Roaming\code-Insiders\User\keybindings.json
。(我在桌面上运行Windows,但在Linux上运行远程开发。)
如果我想进一步了解这一点,我会更新。但这并不容易,因为:
- 在shell中无法真正执行本机操作:
- VS代码中不存在用于在终端中突出显示文本的命令AFAICS(仅在编辑器中)
zsh
而不是bash
。它之所以能够工作,是因为zsh有一个名为zle
的工具,它允许您标记区域,这是通常由控制台主机处理的功能
*-Ctrl-C for clipboard copy对我不起作用,因为我使用的是远程docker和本机Windows OpenSSH,它不允许X11转发;如果这不适用于您,我建议尝试使用和xsel(或xclip)。在我的场景中,我尝试使用tmux和/或文件的输出选择,并执行vscode文件监视任务
感谢在这里回答问题的人:
我们有SSO,所以我在我的dev容器中使用一个非root用户,该用户的用户名与我的桌面用户名相同,并且我依赖一个用我的桌面用户名标记的预构建图像
在这些步骤中,我安装了zgen,这是一个简单的插件管理器,然后我使用它安装zsh autosuggestions、zsh history substring search和zsh-syntax-highlighting.git。我无法让oh my zsh工作,zgen似乎是最轻量级的选择
这里没有显示powerlevel10k主题,它也使用zgen加载
如果您只需要Ctrl-Shift-Left等功能,则可以跳过zgen位,但这将是一个错过的机会:-)
devcontainer.json
:
{
"name": "devcontainer",
"image": "devcontainer:${env:USERNAME}",
"runArgs": [
// Username
"-u", "${env:USERNAME}",
// ...etc...
Dockerfile
:
RUN echo "Setting up user ${USERNAME} with UID ${USER_UID} and GID ${USER_GID}" \
&& groupadd --gid $USER_GID $USERNAME \
&& useradd -s /usr/bin/zsh --uid $USER_UID --gid $USER_GID -m $USERNAME
RUN echo 'Installing zsh and zgen...' \
&& apt-get update \
&& apt-get install -y zsh \
&& git clone https://github.com/tarjoilija/zgen /home/${USERNAME}/.zgen --depth=1 \
&& chown ${USERNAME}:${USERNAME} /home/${USERNAME}/.zgen -R \
#
&& echo 'Installing fonts...' \
&& apt-get install -y fonts-powerline \
#
# Clean up
&& apt-get autoremove -y \
&& apt-get clean -y \
&& rm -rf /var/lib/apt/lists/*
COPY --chown=${USERNAME}:${USERNAME} .zshrc /home/${USERNAME}/.zshrc
RUN chmod +x /home/${USERNAME}/.zshrc
…显然,您需要将USERNAME/USER\UID/USER\GID作为构建参数传入
.zshrc
:
# Set up the prompt
autoload -Uz promptinit
promptinit
prompt adam1
setopt histignorealldups sharehistory
# Use emacs keybindings even if our EDITOR is set to vi
bindkey -e
# Keep 1000 lines of history within the shell and save it to ~/.zsh_history:
HISTSIZE=1000
SAVEHIST=1000
HISTFILE=~/.zsh_history
# Use modern completion system
autoload -Uz compinit
compinit
zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*' completer _expand _complete _correct _approximate
zstyle ':completion:*' format 'Completing %d'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' menu select=2
eval "$(dircolors -b)"
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*'
zstyle ':completion:*' menu select=long
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*' use-compctl false
zstyle ':completion:*' verbose true
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
# load zgen
source "${HOME}/.zgen/zgen.zsh"
zgen load zsh-users/zsh-autosuggestions
zgen load zsh-users/zsh-history-substring-search
zgen load zsh-users/zsh-syntax-highlighting.git
# Windows-style keyboard bindings!
# https://stackoverflow.com/questions/5407916/zsh-zle-shift-selection
r-delregion() {
if ((REGION_ACTIVE)) then
zle kill-region
else
local widget_name=$1
shift
zle $widget_name -- $@
fi
}
r-deselect() {
((REGION_ACTIVE = 0))
local widget_name=$1
shift
zle $widget_name -- $@
}
r-select() {
((REGION_ACTIVE)) || zle set-mark-command
local widget_name=$1
shift
zle $widget_name -- $@
}
for key kcap seq mode widget (
sleft kLFT $'\e[1;2D' select backward-char
sright kRIT $'\e[1;2C' select forward-char
sup kri $'\e[1;2A' select up-line-or-history
sdown kind $'\e[1;2B' select down-line-or-history
send kEND $'\E[1;2F' select end-of-line
send2 x $'\E[4;2~' select end-of-line
shome kHOM $'\E[1;2H' select beginning-of-line
shome2 x $'\E[1;2~' select beginning-of-line
left kcub1 $'\EOD' deselect backward-char
right kcuf1 $'\EOC' deselect forward-char
end kend $'\EOF' deselect end-of-line
end2 x $'\E4~' deselect end-of-line
home khome $'\EOH' deselect beginning-of-line
home2 x $'\E1~' deselect beginning-of-line
csleft x $'\E[1;6D' select backward-word
csright x $'\E[1;6C' select forward-word
csend x $'\E[1;6F' select end-of-line
cshome x $'\E[1;6H' select beginning-of-line
cleft x $'\E[1;5D' deselect backward-word
cright x $'\E[1;5C' deselect forward-word
del kdch1 $'\E[3~' delregion delete-char
bs x $'^?' delregion backward-delete-char
) {
eval "key-$key() {
r-$mode $widget \$@
}"
zle -N key-$key
bindkey ${terminfo[$kcap]-$seq} key-$key
}
他想在终点站做这件事。您的命令只能在编辑器中工作。