Bash, Vim tips and tricks


hr plugin c-a to increment



nnoremap td "=strftime("%Y-%m-%d")P nnoremap ts "=strftime("%Y-%m-%d %H:%M:%S")P

hidden commands Common bash / vim / node tools used


# Auto-complete on tab instead of tab-tab
set show-all-if-ambiguous on


Generate current date
Increment / decrement
Toggle boolean
visql - edit sqlite files

bash process tldr instead of man pages for basic functionality


; * #

fzf, especially alt - c to go to directory

:lopen, see error list, goes with :lnext, :lprev

@:, repeat last command, goes together with all commands!

capital I capital A search replace add newline \r

# Add ! at the end of a command to toggle a command (for instance, toggle spellcheck)
:set spell!

# Execute command from terminal without exiting vim (<command> can for instance be wc to count the number of words)
:! <command> %

# Reading command output (for instance read directory content)
:r ! ls -1 <path>

# Copy file content to current buffer
:r textfile

# Repeat last colon command

# Display Word count
g + ctrl-g

# Show errors

# Execute cmd in each valid entry in quickfix list (for instance find-replace)
: cdo s/pattern/newpattern/g

The in the mapping tells vim that after the : is entered the Control+U combination should be used to clear the command line, eliminating the automatically inserted range leaving the command line looking like:

the command, :! !{motion}{filter} Filter {motion} text lines through the external program {filter}.


git config --global core.excludesfile '~/.gitignore'[aZ]

ctrl-x ctrl-e, edit current line in bash in vim

g- g+, step backward/forward in time

run vim between pipes

* vifm *

* grv git-repository-viewer *

:read !ls -l



; command

g+ g-

. command

Remove current file :!rm %:p


gD global definition gd local definition gf file under cursor g] go to tag definition remapped to CTRL-B CTRL-T go back

CTRL-e-escape, escape shell variables like !! becomes the last command (cat for instance)

:vsplit :split open buffers

zc, zo, zM

Search replace all buffers :bufdo %s/pattern/replace/ge | update vim quickfix window

C-I to jump forward C-O to jump backwards works for both tags and navigation

vifm vimdiff

:qa ctrl - w - v open vertical split window