Nvim recognizes the following events. Names are case-insensitive.
BufAdd
Just after creating a new buffer which is
added to the buffer list, or adding a buffer
Command | Description |
---|---|
:autocmd |
Lists all currently defined auto commands in Neovim. |
:autocmd {event} |
Shows auto commands for a specific event (e.g., BufWritePost ). |
:verbose :autocmd {event} |
Provides detailed information about auto commands for a specific event |
:augroup {group} | autocmd | augroup END |
Displays all auto commands within a specific group. |
:autocmd * {pattern} |
Lists all auto commands that match a specific pattern (e.g., *.lua ). |
Telescope autocommands |
Lists all auto commands and fuzzy find. |
Command | Description |
---|---|
:%s/old/new/g |
Replace all occurrences of 'old' with 'new' in the entire file |
:s/old/new/g |
Replace all occurrences of 'old' with 'new' in the current line |
:s/\Cold/new/g |
Case-sensitive replace of 'old' with 'new' in the current line |
:s/\v(\d+)-(\d+)/\2-\1/g |
Swap two groups of digits separated by a hyphen in the current line |
:g/^$/d |
Delete all empty lines in the file |
:g/pattern/norm gU$ |
Convert matching lines to uppercase |
`:argdo %s/old/new/gc | update` |
#!/usr/bin/env bash | |
# The set -e option instructs bash to immediately exit if any command has a non-zero exit status | |
# The set -u referencing a previously undefined variable - with the exceptions of $* and $@ - is an error | |
# The set -o pipefaile if any command in a pipeline fails, that return code will be used as the return code of the whole pipeline | |
# https://bit.ly/37nFgin | |
set -o pipefail | |
help_function() { | |
echo "Usage: __open_file.sh [query] [-h|--help]" |
function _G.yank_matching_lines() | |
local search_pattern = vim.fn.getreg('/') | |
if search_pattern ~= '' then | |
local matching_lines = {} | |
for line_number = 1, vim.fn.line('$') do | |
local line = vim.fn.getline(line_number) | |
if vim.fn.match(line, search_pattern) ~= -1 then | |
table.insert(matching_lines, line) | |
end | |
end |
! this should be highlighted !
With time the .kube/config file will contain a mix of dev, test and prod cluster references.
It is easy to forget switching off from a prod cluster context and make a mistake and run for example kubectl delete ns crossplane-system
.
Use the following setup to avoid these kinds of errors and keep clusters separate.
#!/usr/bin/env bash | |
# Find a repo for my user and cd into it, clone and cd if not found on disk | |
function repo() { | |
# If repo name not provided, prompt for it rather than error out | |
if [[ -z "$1" ]]; then | |
export repo=$(ghs -u Piotr1215 | sed 's:.*/::') | |
else | |
export repo=$(ghs -u Piotr1215 $1 | sed 's:.*/::') | |
fi |
# Detect operating system in Makefile. | |
# Author: He Tao | |
# Date: 2015-05-30 | |
OSFLAG := | |
ifeq ($(OS),Windows_NT) | |
OSFLAG += -D WIN32 | |
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64) | |
OSFLAG += -D AMD64 | |
endif |
General purpose Ubuntu 20.04 Instance
curl -sfL https://get.k3s.io | sh -