Vim Searching – Advanced Tips

Summary of Commands

# Toggle 'hlsearch' option
:set hls
:set nohls

# Toggle 'ignorecase' option
:set ignorecase
:set noignorecase

# Clear screen of ALL highlighted matches
# with command 'nohls'
:nohls

# Remove "S" from 'shortmess' option
:set shortmess-=S

# Make pattern case-insensitive
# Assumes ':set noignorecase'
/the\c

# Make pattern case-sensitive
# Assumes ':set ignorecase'
/the\C

TMUX Copy Mode – Part 1 & 2

Part 1

Using TMUX but can’t scroll your output? This video is for you!

Here we introduce TMUX’s Copy Mode.

Copy Mode is how you

  1. View
  2. Search and
  3. Copy your TMUX history

Summary of Copy Mode Commands (defaults)

Summary of TMUX Commands

# Display current value for option 'mode-keys'
show-options -g mode-keys

# Set to vi-style key bindings
set-option -g mode-keys vi

# Set to emacs-style key bindings
set-option -g mode-keys emacs

Part 2

Summary of TMUX Commands

# Set key binding mode to vi OR emacs
set-option -g mode-keys vi
set-option -g mode-keys emacs

# List emacs key bindings
list-keys -T copy-mode C-r
list-keys -T copy-mode C-s

# List Vi key bindings
list-keys -T copy-mode-vi ?
list-keys -T copy-mode-vi /
list-keys -T copy-mode-vi L
list-keys -T copy-mode-vi M
list-keys -T copy-mode-vi H

# Redefine Vi searching
bind-key -T copy-mode-vi ? command-prompt -i -I "#{pane_search_string}" -p "(search up)" "send -X search-backward-incremental \"%%%\""
bind-key -T copy-mode-vi / command-prompt -i -I "#{pane_search_string}" -p "(search down)" "send -X search-forward-incremental \"%%%\""

# Redefine Emacs commands:
# bottom-line
# middle-line and
# top-line
bind-key -T copy-mode L send-keys -X bottom-line
bind-key -T copy-mode M send-keys -X bottom-line
bind-key -T copy-mode H send-keys -X bottom-line


NEVER GET LOST IN VIM AGAIN!

Are you new to Vim but every time you launch it..

Exiting feels like trying to escape a blackhole! πŸŒŒπŸš€

I just launched my Vim Crash Course and it will show you how to edit files, never get lost, and exit once and for all. 😌

https://stan.store/raychavez/p/vim-crash-course-for-linux-users

TMUX Options

The following options are from TMUX version 3.2a

You can view the details of each option in the tmux man page

man tmux

Video Demo

Available server options

backspace
buffer-limit
command-alias[0]
command-alias[1]
command-alias[2]
command-alias[3]
command-alias[4]
command-alias[5]
copy-command
default-terminal
editor
escape-time
exit-empty
exit-unattached
extended-keys
focus-events
history-file
message-limit
set-clipboard
terminal-overrides
terminal-features[0]
terminal-features[1]
user-keys

Available Session Options

activity-action
assume-paste-time
base-index
bell-action
default-command
default-shell
default-size
destroy-unattached
detach-on-destroy
display-panes-active-colour
display-panes-colour
display-panes-time
display-time
history-limit
key-table
lock-after-time
lock-command
message-command-style
message-style
mouse
prefix
prefix2
renumber-windows
repeat-time
set-titles
set-titles-string
silence-action
status
status-bg
status-fg
status-format[0]
status-format[1]
status-interval
status-justify
status-keys
status-left
status-left-length
status-left-style
status-position
status-right
status-right-length
status-right-style
status-style
update-environment[0]
update-environment[1]
update-environment[2]
update-environment[3]
update-environment[4]
update-environment[5]
update-environment[6]
update-environment[7]
visual-activity
visual-bell
visual-silence
word-separators

Available window options

aggressive-resize
allow-rename
alternate-screen
automatic-rename
automatic-rename-format
clock-mode-colour
clock-mode-style
copy-mode-match-style
copy-mode-current-match-style
copy-mode-mark-style
main-pane-height
main-pane-width
mode-keys
mode-style
monitor-activity
monitor-bell
monitor-silence
other-pane-height
other-pane-width
pane-active-border-style
pane-base-index
pane-border-format
pane-border-lines
pane-border-status
pane-border-style
remain-on-exit
synchronize-panes
window-active-style
window-size
window-style
window-status-activity-style
window-status-bell-style
window-status-current-format
window-status-current-style
window-status-format
window-status-last-style
window-status-separator
window-status-style
wrap-search
xterm-keys

Available Pane Options

allow-rename
alternate-screen
remain-on-exit
synchronize-panes
window-active-style
window-style

Advanced Hot Keys (Bash)

Command Summary

Bash’s default is to use these Emacs-style commands:

###################
# 
# Control Modifier
#
###################
# Move up your command history
ctrl-p
# Move down your command history
ctrl-n
# Move back one character at a time
ctrl-b
# Move forward one character at a time
ctrl-f
# Front of the line
ctrl-a
# End of the line
ctrl-e
# Delete one character at a time
ctrl-d
# Backspace one character at a time
ctrl-h
# Delete everything after the cursor, including underneath (inclusive)
ctrl-k
# To delete everything before the cursor (exclusive)
ctrl-u
###############
#
# Alt Modifier
#
###############
# Move back one word at a time
alt-b
# Move forward one word at a time
alt-f
# Delete a word at a time
alt-d
# Backspace one word at a time
ctrl-w

Video Demo:

Supercharge your bash prompt w/ git info

Here’s the source code for the bash function and PS1 variable:

# Bash function
my_git() {
GIT_BRANCH=$(git branch --all 2> /dev/null | egrep "^\*" | cut -d ' ' -f 2 )
if [[ -z "$GIT_BRANCH" ]]; then
       echo "" #not in a Git repo
else
    if [ $(git status | egrep "^Untracked" -c) -ge 1 ]; then
        #ANSI code: Red
        echo -e "(\033[0;31m$GIT_BRANCH\033[0m) "
    elif  [ $(git status | egrep "^Changes" -c) -ge 1 ]; then
        #ANSI code: Yellow
        echo -e "(\033[0;33m$GIT_BRANCH\033[0m) "
    else
        #ANSI code: Green
        echo -e "(\033[0;32m$GIT_BRANCH\033[0m) "
    fi
fi
}
# PS1 variable:
export PS1="\[\e]0;\u@\h: \w\a\]\u@\h:\w$ \$(my_git)"

Full Demo: