Post History
MWE To reproduce: Add bindkey -v to your ~/.zshrc. Invoke python interpreter: python. Type something into the prompt without hitting ENTER: this = "this" + "that". Press ESC and try any vim ...
#4: Post edited
# Minimum Working Example- To reproduce:
- 1. Add `bindkey -v` to your `~/.zshrc`.
- 2. Invoke python interpreter: `python`.
- 3. Type something into the prompt without hitting `ENTER`: `this = "this" + "that"`.
- 4. Press `ESC` and try any `vim` bindings successively: `bb`.
- # Problem
- The behavior is not consistent. Sometimes the cursor highlighting does not match the mode (see Notes for code used), sometimes I have to press `ESC` before each `vim` key entry.
- # Notes
- Using Arch Linux, `st` terminal, `zsh`, and `python` 3.10.9.
- I am using the following code in my `~/.zshrc` to change the cursor to indicate mode:
- ```sh
- # change cursor shape for different vi modes
- cursor_mode() {
- # See https://ttssh2.osdn.jp/manual/4/en/usage/tips/vim.html for cursor shapes
- cursor_block='\e[2 q'
- cursor_beam='\e[6 q'
- function zle-keymap-select {
- if [[ ${KEYMAP} == vicmd ]] ||
- [[ $1 = 'block' ]]; then
- echo -ne $cursor_block
- elif [[ ${KEYMAP} == main ]] ||
- [[ ${KEYMAP} == viins ]] ||
- [[ ${KEYMAP} = '' ]] ||
- [[ $1 = 'beam' ]]; then
- echo -ne $cursor_beam
- fi
- }
- zle-line-init() {
- echo -ne $cursor_beam
- }
- zle -N zle-keymap-select
- zle -N zle-line-init
- }
- cursor_mode
- ```
- # MWE
- To reproduce:
- 1. Add `bindkey -v` to your `~/.zshrc`.
- 2. Invoke python interpreter: `python`.
- 3. Type something into the prompt without hitting `ENTER`: `this = "this" + "that"`.
- 4. Press `ESC` and try any `vim` bindings successively: `bb`.
- # Problem
- The behavior is not consistent. Sometimes the cursor highlighting does not match the mode (see Notes for code used), sometimes I have to press `ESC` before each `vim` key entry.
- # Notes
- Using Arch Linux, `st` terminal, `zsh`, and `python` 3.10.9.
- I am using the following code in my `~/.zshrc` to change the cursor to indicate mode:
- ```sh
- # change cursor shape for different vi modes
- cursor_mode() {
- # See https://ttssh2.osdn.jp/manual/4/en/usage/tips/vim.html for cursor shapes
- cursor_block='\e[2 q'
- cursor_beam='\e[6 q'
- function zle-keymap-select {
- if [[ ${KEYMAP} == vicmd ]] ||
- [[ $1 = 'block' ]]; then
- echo -ne $cursor_block
- elif [[ ${KEYMAP} == main ]] ||
- [[ ${KEYMAP} == viins ]] ||
- [[ ${KEYMAP} = '' ]] ||
- [[ $1 = 'beam' ]]; then
- echo -ne $cursor_beam
- fi
- }
- zle-line-init() {
- echo -ne $cursor_beam
- }
- zle -N zle-keymap-select
- zle -N zle-line-init
- }
- cursor_mode
- ```
#3: Post edited
Vim bindings not working in terminal python interpretter
- Vim key bindings not working in terminal python interpreter
# MWE- 1. Add `bindkey -v` to your `~/.zshrc`.
- 2. Invoke python interpreter: `python`.
3. Type something into the prompt without hitting `ENT`: `this = "this" + "that"`.4. Press `ESC` and try any vim bindings successively: `bb`.- # Problem
The behavior is not consistent. Sometimes the cursor highlighting does not match the mode (see Notes for code used), sometimes I have to press `ESC` before each vim key entry.- # Notes
Using Arch Linux, st terminal, zsh, and python 3.10.9.- I am using the following code in my `~/.zshrc` to change the cursor to indicate mode:
- ```sh
- # change cursor shape for different vi modes
- cursor_mode() {
- # See https://ttssh2.osdn.jp/manual/4/en/usage/tips/vim.html for cursor shapes
- cursor_block='\e[2 q'
- cursor_beam='\e[6 q'
- function zle-keymap-select {
- if [[ ${KEYMAP} == vicmd ]] ||
- [[ $1 = 'block' ]]; then
- echo -ne $cursor_block
- elif [[ ${KEYMAP} == main ]] ||
- [[ ${KEYMAP} == viins ]] ||
- [[ ${KEYMAP} = '' ]] ||
- [[ $1 = 'beam' ]]; then
- echo -ne $cursor_beam
- fi
- }
- zle-line-init() {
- echo -ne $cursor_beam
- }
- zle -N zle-keymap-select
- zle -N zle-line-init
- }
- cursor_mode
- ```
- # Minimum Working Example
- To reproduce:
- 1. Add `bindkey -v` to your `~/.zshrc`.
- 2. Invoke python interpreter: `python`.
- 3. Type something into the prompt without hitting `ENTER`: `this = "this" + "that"`.
- 4. Press `ESC` and try any `vim` bindings successively: `bb`.
- # Problem
- The behavior is not consistent. Sometimes the cursor highlighting does not match the mode (see Notes for code used), sometimes I have to press `ESC` before each `vim` key entry.
- # Notes
- Using Arch Linux, `st` terminal, `zsh`, and `python` 3.10.9.
- I am using the following code in my `~/.zshrc` to change the cursor to indicate mode:
- ```sh
- # change cursor shape for different vi modes
- cursor_mode() {
- # See https://ttssh2.osdn.jp/manual/4/en/usage/tips/vim.html for cursor shapes
- cursor_block='\e[2 q'
- cursor_beam='\e[6 q'
- function zle-keymap-select {
- if [[ ${KEYMAP} == vicmd ]] ||
- [[ $1 = 'block' ]]; then
- echo -ne $cursor_block
- elif [[ ${KEYMAP} == main ]] ||
- [[ ${KEYMAP} == viins ]] ||
- [[ ${KEYMAP} = '' ]] ||
- [[ $1 = 'beam' ]]; then
- echo -ne $cursor_beam
- fi
- }
- zle-line-init() {
- echo -ne $cursor_beam
- }
- zle -N zle-keymap-select
- zle -N zle-line-init
- }
- cursor_mode
- ```
#1: Initial revision
Vim bindings not working in terminal python interpretter
# MWE
1. Add `bindkey -v` to your `~/.zshrc`.
2. Invoke python interpreter: `python`.
3. Type something into the prompt without hitting `ENT`: `this = "this" + "that"`.
4. Press `ESC` and try any vim bindings successively: `bb`.
# Problem
The behavior is not consistent. Sometimes the cursor highlighting does not match the mode (see Notes for code used), sometimes I have to press `ESC` before each vim key entry.
# Notes
Using Arch Linux, st terminal, zsh, and python 3.10.9.
I am using the following code in my `~/.zshrc` to change the cursor to indicate mode:
```sh
# change cursor shape for different vi modes
cursor_mode() {
# See https://ttssh2.osdn.jp/manual/4/en/usage/tips/vim.html for cursor shapes
cursor_block='\e[2 q'
cursor_beam='\e[6 q'
function zle-keymap-select {
if [[ ${KEYMAP} == vicmd ]] ||
[[ $1 = 'block' ]]; then
echo -ne $cursor_block
elif [[ ${KEYMAP} == main ]] ||
[[ ${KEYMAP} == viins ]] ||
[[ ${KEYMAP} = '' ]] ||
[[ $1 = 'beam' ]]; then
echo -ne $cursor_beam
fi
}
zle-line-init() {
echo -ne $cursor_beam
}
zle -N zle-keymap-select
zle -N zle-line-init
}
cursor_mode
```
