Commands I Use Frequently (Vim, Bash, more)

VIM:


Numerate numerable element in visual selection:

visual select - g - ctrl+a

example:

![](/serv1.png)
![](/serv1.png)
![](/serv1.png)
![](/serv1.png)
![](/serv1.png)
![](/serv1.png)
![](/serv1.png)

![](/serv1.png)
![](/serv2.png)
![](/serv3.png)
![](/serv4.png)
![](/serv5.png)
![](/serv6.png)
![](/serv7.png)

Visual block:

ctrl-v - select - shift+I - write -  esc

example: say we want to append ![] to the beginning of multiple lines.

(/serv1.png)
(/serv1.png)
(/serv1.png)
(/serv1.png)
(/serv1.png)
(/serv1.png)
(/serv1.png)

It can be done simply with the above command.

![](/serv1.png)
![](/serv1.png)
![](/serv1.png)
![](/serv1.png)
![](/serv1.png)
![](/serv1.png)
![](/serv1.png)

Copy and paste from vim

"*y  "*p 

to “yank” text into the * register then to paste …or

"+y then "+p

Capitalize first letter of each word in selected region

s/\<./\u&/g

\< matches the start of a word

. matches the first character of a word

\u tells Vim to uppercase the following character in the substitution string (&)

& means substitute whatever was matched on the left-hand side

g means substitute all matches, not only the first

BASH:


Find what directory a file is in.

example

find . -name "*.py" -type f 

locate any file name ending in .py

find . -name "*.py" -type f -exec cat {} + > all.py

locate any file name ending in .py, then execute cat for each file into a new
file called all.py

Turn down brightness and soften screen (reduce bluelight)

example

xrandr --output VGA-1 --brightness .80 && redshift -O 2500

Concatinate multiple files into one:

cat *.html > output.html

Convert .docx to pdf

 libreoffice --headless --convert-to pdf *.docx   

New terminal opens in most recent working directory:

#save path on cd
function cd {
    builtin cd $@
    pwd > ~/.last_dir
}


#restore last saved path
if [ -f ~/.last_dir ]
    then cd `cat ~/.last_dir`
fi

WEBSITE:


Sync local copy of website to website server

rsync -uvrP --delete-after /home/paul/new-site2/public/ root@paulmackay.xyz:/var/www/paulmackay/