06 February 2026
on ubuntu terminal, how to remove all the spaces from all the file names in a directory?
23 May 2022
How to delete all the lines which contain a pattern in vim?
The ex command g is very useful for acting on lines that match a pattern. You can use it with the d command, to delete all lines that contain a particular pattern, or all lines that do not contain a pattern.
For example, to delete all lines containing "profile" (remove the /d to show the lines that the command will delete):
:g/profile/d
More complex patterns can be used, such as deleting all lines that are empty or that contain only whitespace:
:g/^\s*$/d
To delete all lines that do not contain a pattern, use g!, like this command to delete all lines that are not comment lines in a Vim script:
:g!/^\s*"/d
Note that g! is equivalent to v, so you could also do the above with:
:v/^\s*"/d
The next example shows use of \| ("or") to delete all lines except those that contain "error" or "warn" or "fail" (:help pattern):
:v/error\|warn\|fail/d
11 June 2021
How to create an alias command in git to display a log in graph?
How to create an alias command in git to display a log in graph?
$alias graph="git log --all --oneline --graph --decorate"
(I find that it outputs the same as without '--decorate'.)
Note:
'--oneline' is a shorthand for both '--pretty=oneline' and '--abbrev-commit' used together.
-----------------------------------------------------------------------------------------
I find the 2 following commands are very helpful,
1.
$git log --all --oneline --graph
2.
$git show-branch --all --more=1000
(you can replace 1000 with any number, according to your requirements.)