Cutting, Copying, Pasting From Vim To Clipboard And Back

1 Cut, Copy and Paste using the computer keyboard

Everybody knows how to use the keyboard combinations Ctrl-c, Ctrl-x, and Ctrl-v in Windows and Linux (or Cmd-c, Cmd-x and Cmd-v in macOS) to copy, cut and paste text across applications.

Many think that those combinations are universal and work with any application.

But Vim and gVim are different, they use another system to exchange information with the rest of the IT world.

For example, in Vim under Linux, the key combination Ctrl-v corresponds to the visual block function and does not affect the pasting text.

I wrote this article to remind me, as a non-programmer, the key combinations to be used in the Vim world to share text with other applications.

2 Vim and the clipboard

Vim uses an original resource to exchange text with other applications.

If you press the Vim (or gVim) :reg command, you can notice a list of items beginning with a double quotation mark (“) and followed by a symbol, a letter or a number: these are the registers.

Vim uses a specific register to interact with the system clipboard and, consequently, with other applications.

This specific clipboard register is identified with the mathematical plus symbol (+) 1

3 From Vim to the Clipboard

If you need to transfer information from Vim to other environments you must use the key combination ​"+y to copy the text and ​"+x to cut it from the original document.

Pay attention to the following table:

KeyWhat is?
The registers symbol
+The clipboard register symbol
xThe letter to cut the text
yThe letter to copy the text

Then you have to press three keys in sequence:

  1. ​”​
  2. +
  3. x or y

In both cases, the cut or copied text is sent also to the clipboard and can be pasted outside Vim using the usual Ctrl-v command, in Windows and Linux, or Cmd-v in macOS.

4 From the Clipboard to Vim

The reverse operation is also quite simple. You can transfer your text copied from the clipboard using the string ​"+gP.

Let’s analyze every single component of the string:

P” means paste before the current position.

The “g” key puts the cursor after the pasted text.

Then “gP” command produces the following result: Paste before the current position, placing the cursor after the pasted text.

If you don’t use g the cursor will be placed on the last letter of the pasted text and you’ll waste time to advance the cursor by one character.

In Vim philosophy everything must be optimized, also the single movements of the cursor!

5 Some key shortcuts in gVim

In some cases, it is also possible to use key shortcuts in gVim.

They mainly work in MS Windows but some of the work also in several Linux distributions. I can directly confirm the working in Mint, Fedora, Ubuntu, Antergos for the pasting shortcut (see list below) but not the same for the others.

The following is the list of shortcuts:

ShortcutWhat happens?
Shift+DeleteCut text and copy it in the clipboard
Ctrl+InsertCopy text in the clipboard
Shift+InsertPaste text from the clipboard into a document

Thank You for Your attention.



There’s also another symbol for the clipboard: the asterisk (*): it produces almost the same results of the plus symbol but in GNU/Linux OS it saves information specifically for the middle mouse button.


Showing Current Date, Day, Or Time In WordPress

WordPress does not come with a default widget or block to display current date or time.

However, you can still display current date or time using some very simple code.

You can add this simple code in your WordPress theme’s template files where you want to display the time.

1<?php echodate(get_option('date_format')); ?>

This code simply prints the current date using the date format set in your WordPress settings. You can change the date format by visiting the Settings » General page.

You can also use your own formatting tags to output the date in any other format. For instance, using the following code you can print the date in month, day, and year format.

1<?php echodate('F j, Y'); ?>

This method allows you to directly add the code into WordPress theme files, but it is not very flexible. What if you wanted to display current date and time inside a WordPress post, page, or a sidebar widget?

This next method allows you to add date and time anywhere on your site.


Reusable Cursor Hover Function In JavaScript

function hover(element, enter, leave){
  element.addEventListener('mouseenter', enter)
  element.addEventListener('mouseleave', leave)

You can then pass your element and callback functions like so.

hover(document.querySelector('h1'), e => {
  // On hover"logo__container--hover")
}, e => {
  // On exit hover"logo__container--hover")

You can reduce the lines of code too by modifying the hover function.

function hover(element, className){
  element.addEventListener('mouseenter', e => element.classList.add(className))
  element.addEventListener('mouseleave', e => element.classList.remove(className))

Then use it like so.

hover(document.querySelector('h1'), "logo__container--hover")

You can reuse this now for multiple elements scalably.


Getting Theme URL In WordPress

If You wish to retrieve a template’s directory URI for the active theme, use


Using get_template_directory_uri() to link a static image with its correct path in html :

1<img src="<?php echo get_template_directory_uri(); ?>/images/logo.png"width=""height=""alt=""/>


Adding An Event Listener To Multiple Elements With JavaScript

Using a loop

The loop is the simplest one conceptually.

You can call querySelectorAll() on all elements with a specific class, then use forEach() to iterate on them:

document.querySelectorAll('.some-class').forEach(item => {
  item.addEventListener('click', event => {
    //handle click

If you don’t have a common class for your elements you can build an array on the fly:

[document.querySelector('.a-class'), document.querySelector('.another-class')].forEach(item => {
  item.addEventListener('click', event => {
    //handle click

Using event bubbling

Another option is to rely on event bubbling and attach the event listener on the body element.

The event is always managed by the most specific element, so you can immediately check if that’s one of the elements that should handle the event:

const element1 = document.querySelector('.a-class')
const element2 = document.querySelector('.another-class')

body.addEventListener('click', event => {
  if ( !== element1 && !== element2) {
  //handle click


How To Include A PHP File In WordPress

This little “PHP include” guide, will show you how to include a PHP-file in your WordPress theme (using a relative path). This snippet isn’t so much a “WordPress snippet”, but really just the PHP include function, using WordPress get_template_directoryto get the relative path for the file. Why you should …

This little “PHP include” guide, will show you how to include a PHP-file in your WordPress theme (using a relative path). This snippet isn’t so much a “WordPress snippet”, but really just the PHP include function, using WordPress get_template_directoryto get the relative path for the file.

Why you should choose a relative path and not an absolute/static path

When you want to include a PHP file (or image file, HTML file, etc.), it is required to specify a specific path that instructs the webserver, on where the webserver should locate the specific file. There are multiple ways to go about this, such as:

  • Using a absolute/static path (not recommended) – specifying the location of a file or directory from the root directory(/).
  • Using a relative path (best practice) – the path related to the present working directly(pwd), starting at your current directory and never starts with a “/”.

The WordPress get_template_directory() function

The build-in WordPress function get_template_directory, retrieves the current theme directory by returning an absolute server path (eg: /home/user/public_html/wp-content/themes/my_theme), and not a URI.

In case you are using a WordPress child theme

In case you are using a child theme, the absolute path to the parent theme directory will be returned – and this will not work. If you are using a child theme, then you would have to use the WordPress function: get_stylesheet_directory() instead, to get the absolute path to the child theme directory.

How to include a PHP file in a WordPress theme

In this PHP include example, we are going to use a relative path, using the WordPress build in function: get_template_directory.

<?php include get_template_directory() . '/inc/yourfile.php'; ?>

How to include a PHP file in a WordPress child theme

In this PHP include example, we are going to use a relative path, using the WordPress build in function: get_stylesheet_directory().

<?php include get_stylesheet_directory() . '/inc/yourfile.php'; ?>

How To Check Fonts Installed From Command Line

The best and simplest way is to use console command (this command should be available for all ubuntu-based distributions) :


Example output (stripped) :

/usr/share/fonts/truetype/lato/Lato-Medium.ttf: Lato,Lato Medium:style=Medium,Regular
/usr/share/fonts/truetype/tlwg/TlwgTypo-Bold.ttf: Tlwg Typo:style=Bold
/usr/share/fonts/truetype/lato/Lato-SemiboldItalic.ttf: Lato,Lato Semibold:style=Semibold Italic,Italic
/usr/share/fonts/truetype/dejavu/DejaVuSerif-Bold.ttf: DejaVu Serif:style=Bold
/usr/share/fonts/truetype/noto/NotoSansThai-Regular.ttf: Noto Sans Thai:style=Regular

From MAN :

fc-list - list available fonts

To check all available options use MAN (manual): man fc-list


Social Media ::: Free Speech As Product

We believe that social media sells us free speech.

While it does not, or at least has not, most of us believe it should.

We believe it should.

We believe that free speech is just as much a commodity as choice. Or, no choice, since that is what these platforms actually sell.

No choice seems dystopian. And yet, despite what those of us socialized in these united states have been spoon fed, we are constantly purchasing “no choice” branded as convenience.

Algorithms. This decade’s buzzword. Algorithms. Computer programs attached to interfaces that choose what we see based on past consumption patterns. We believe that we are creating content. We believe that we are providing value.

What we believe is belied by this beast’s true nature.

Many of us still believe a company’s objective is to flip money. To secure a return of investment. I no longer believe this. Corporations, like nations, like governments, have an existentialist position. That is, they exist, and they wish to continue to exist. This need to exist is precarious for pure profits.

Content creation, free speech, and other illusions are sold to us. We are told we have a “platform”. Is that what we have?

It seems to me, that we only have a needle in our arms draining us of valuable Life blood. Ideas fused with electromagnetic designs. Bright screens hold us like gnats to a porch light. And how much of this free speech has changed our reality? How much has societal abuse waned?

Not much at all, really.

With all this “wokeness’ abounding, we would think school shootings would have simmered down.

With all this “wokeness” abounding, we would think police killings would have simmered down.

With all this “wokeness” abounding, we would think Black pregnant WOMEN would have less fatal pregnancies.

But muthaphukkkin’ alas…