Share what you know about vim anti-patterns

Vim anti patterns are actions that could be done with fewer keystrokes and faster, for example, jumping to the line 5 5gg copying the line yy jumping back with Ctrl-o and finally pressing p. All these actions could be just one 5t.

I also would like to include ways of running macros faster, things like:

:silent! argdo :noautocmd norm! @a

To disable autocommands for just one command using the “:noautocmd” command modifier. This will set ‘eventignore’ to “all” for the duration of the
following command.

shell aliases that can help your workflow could be included, things like:

# zsh alias to open the last edited file
alias lvim='vim -c "normal '\''0"'

A ZSH autoloader function to search files using FZF and opening the searched file on vim:

# source:https://stackoverflow.com/a/65375231/2571881
function vif() {
    local fname
    cd ~/.dotfiles
    fname=$(fzf) || return
    vim "$fname"
}
# easy copy and paste from clipboard
(( $+commands[xclip] )) && {
    alias pbpaste='xclip -i -selection clipboard -o'
    alias pbcopy='xclip -selection clipboard'
    alias sclip='xclip -i -selection clipboard -o'
}
# Edit content of clipboard on vim (scratch buffer)
# ~/.zshrc
function _edit_clipboard(){
    # pbpaste | vim -c 'setlocal bt=nofile bh=wipe nobl noswapfile nu'
    pbpaste | vim
}
zle -N edit-clipboard _edit_clipboard
bindkey '^x^v' edit-clipboard
1 Like