It is possible to store any ex: commands in text file and then execute them.
For example. I want to periodically insert current content of some file in other text file.

Do the following:

  • Put to file the following line

:r /etc/hosts
  • Set cursor to this line an execute in command mode:

  • The result is:

:r /etc/hosts   localhost   HOSTNAME

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters



Put current line to buffer with name 'z'


Execute content of buffer 'z' as ex: command

Vim short form:


This command use unnamed buffer register. 'Y' put current string to unnamed register, @" execute content of unnamed register as ex: command. This operate only in Vim and doesn't operate in POSIX vi.


:r!echo 'scale=2; ( 2 + 3 ) / 2' | bc

:r!date --iso-8601=seconds

:r!lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 12.04.4 LTS
Release:    12.04
Codename:   precise

Selectively set 'execute' permission for directories.

Mon 02 June 2014 by Mikhail Basov


Recursively change permissions:
rwx - for directories
rw - for files
rx - for directories
r - for files
rx - for directories
r - for files


chmod -R u+rwX,go+rX,go-w /directory


Quote from HP-UX chmod man page about 'X' (capital X) option:

X    Conditionally add or …
read more

Copy directory tree with access rights but without files

Tue 15 April 2014 by Mikhail Basov

To copy only directory structure with access rights from current directory (./) to target directory (../test1) issue the following command:

read more