I configured Tmux and added some keybindings to it, and I am also using Neovim (without any plugin installed).
The problem is: when I open a file with Neovim inside a Tmux session, I don’t know why, but the last character of the first line is replaced by a 0 (zero). I tested opening with Vim and Nano, but it only happens with Neovim.
Example
Original file:
foo bar
When I open inside Tmux:
foo ba0
I actually solved my problem, but I needed to remove some key bindings to do so, and I don’t see any relation of them with the bug. The bindings are the following in my .tmux.conf
:
bind -n M-P swap-window -d -t '{previous}'
bind -n M-N swap-window -d -t '{next}'
My question is: how can I solve this without removing these bindings and why it solves that? What is the real problem? Is it Neovim or Tmux?
My .tmux.conf
file:
# SETTINGS
# Change prefix
set -g prefix C-Space
# Start window and pane indices at 1.
set -g base-index 1
set -g pane-base-index 1
# Automatically renumber windows
set -g renumber-windows on
# Increase history limit
set -g history-limit 5000
# Use vim keybindings in copy mode
setw -g mode-keys vi
# Change default terminal colors
set -g default-terminal 'screen-256color'
# Remove escape-time
set -sg escape-time 0
# Status bar
set -g status-left ' #S'
set -g status-right '#{battery_color_fg}#[bg=default]#{battery_icon} #{battery_percentage}%#[default] | %a %d/%m/%Y %R'
set -g status-left-length 150
set -g status-right-length 150
set -g status-position top
set -g status-interval 1
set -g status-style bg=default,fg=grey
set -g display-time 1500
set -g window-status-format '#[fg=brightblack]#I:#W#F'
set -g window-status-current-format '#[fg=purple, bold]#I:#W#F'
set -g window-status-separator ' '
set-window-option -g window-style bg=terminal
set-window-option -g window-active-style bg=terminal
# Change pane border style
set -g pane-border-style fg=colour8
set -g pane-active-border-style fg=colour8
set -g status-justify centre
# KEY BINDINGS
# Reload .tmux.conf.
bind r source-file ~/.tmux.conf; display 'Tmux configs reloaded'
# Detach session
bind d detach
bind C-d detach
# Synchronize panes
bind y set synchronize-panes ; display 'synchronize-panes #{?synchronize-panes,on,off}'
# Don't prompt to kill panes/windows and kill with Alt key
bind x kill-pane
bind & kill-window
bind -n M-x kill-pane
bind -n M-& kill-window
# Create tmux window at current directory and append to the current one
bind c new-window -c '#{pane_current_path}' -a -t '{next}'
bind -n M-c new-window -c '#{pane_current_path}' -a -t '{next}'
# Pane switching with Alt key and arrows or vim's "hjkl" style
set-window-option -g remain-on-exit on
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
#bind -n M-h select-pane -L
#bind -n M-j select-pane -D
#bind -n M-k select-pane -U
#bind -n M-l select-pane -R
# Change split window keys
bind -n M-h split-window -h -c '#{pane_current_path}'
bind -n M-v split-window -v -c '#{pane_current_path}'
# Navigate windows with Alt key
bind -n M-p previous-window
bind -n M-n next-window
# Swap windows with Alt key
bind -n M-P swap-window -d -t '{previous}' # Cause of the bug
bind -n M-N swap-window -d -t '{next}' # Cause of the bug
# Go to the last window
bind-key -n M-l last-window
# Turn pane into window with Alt key and append to the current one
bind -n M-b break-pane -a -t '{next}'
# Move panes
bind -n M-H move-pane -h
bind -n M-V move-pane -v
# Mark pane
bind -n M-m select-pane -m ; display 'Pane #{pane_index} marked. Move with #{prefix} + V or #{prefix} + H'
# Easily resize current pane
bind -n M-z resize-pane -Z
# Change layout by pressing Space key
bind Space next-layout
bind C-Space next-layout
# Change rotation by pressing Tab key
bind Tab rotate-window
# Set vi mode for copy mode
unbind [
bind -n C-o copy-mode
bind p paste-buffer
bind -T copy-mode-vi v send-keys -X begin-selection
bind -T copy-mode-vi y send-keys -X copy-selection
# Select windows by number with Alt key
bind -n M-1 select-window -t :=1
bind -n M-2 select-window -t :=2
bind -n M-3 select-window -t :=3
bind -n M-4 select-window -t :=4
bind -n M-5 select-window -t :=5
bind -n M-6 select-window -t :=6
bind -n M-7 select-window -t :=7
bind -n M-8 select-window -t :=8
bind -n M-9 select-window -t :=9
# PLUGINS
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-battery'
# PLUGINS CONFIGURATION
# Tmux battery
set -g @batt_icon_charge_tier8 ''
set -g @batt_icon_charge_tier7 ''
set -g @batt_icon_charge_tier6 ''
set -g @batt_icon_charge_tier5 ''
set -g @batt_icon_charge_tier4 ''
set -g @batt_icon_charge_tier3 ''
set -g @batt_icon_charge_tier2 ''
set -g @batt_icon_charge_tier1 ''
set -g @batt_icon_status_charged ''
set -g @batt_icon_status_charging ''
set -g @batt_color_charge_primary_tier8 'green'
set -g @batt_color_charge_primary_tier7 'green'
set -g @batt_color_charge_primary_tier6 'green'
set -g @batt_color_charge_primary_tier5 'green'
set -g @batt_color_charge_primary_tier4 'green'
set -g @batt_color_charge_primary_tier3 'green'
set -g @batt_color_charge_primary_tier2 'red'
set -g @batt_color_charge_primary_tier1 'red'
set -g @batt_color_status_primary_charged 'green'
set -g @batt_color_status_primary_charging 'green'
# INITIALIZE TMUX PLUGIN MANAGER
run '~/.tmux/plugins/tpm/tpm'
In addition to that, I also received this message when trying to quit (with :q
) without modifying anything:
I solved removing those two binding of .tmux.conf
file. But I still don’t know how this happened.
1