You can edit your crontab file with “
crontab -e“. It worked fine as long as I used vim. However, when I switched to emacs and set the
EDITOR environment variable to point to emacs, I couldn’t edit my crontab file normally. Emacs is started in the background and somehow it caused problems.
I made a script for editing my crontab file. This script sets
EDITOR back to vim, thus “
crontab -e” opens vim. Here is the script:
#!/usr/bin/env bash # crontab_e EDITOR=/usr/bin/vim crontab -e
I call this script “crontab_e”, so it’s easy to remember its name.
You are working in vim and you want to switch quickly to the terminal to do something. Then you want to get back to vim and continue editing where you left off.
Simply do the same you do with other programs:
CTRL+Z: suspends vim and you find yourself in the terminal
- do your terminal business
fg: brings you back to vim
Vim is a very nice text editor but for its full potential, you need a good config. file :) If you are new to vim, you can start with sachet. Sachet is a web application where you select the features you want in your vim editor and it prepares the config. file for you that you can download and install. Simple!
“sachet allows you to handcraft your VIM development environment. By allowing you to select features and functionality that you are comfortable with, sachet generates you a small package with the appropriate configuration files, plugins, and theme so you can leverage the potential of your VIM editor.” (source)
Later on you can customize your
I don’t want to encourage anyone, but if you are interested in customizing your vim editor, check out Learn Vimscript the Hard Way.
“The book is divided roughly into three sections:
- The first covers basic Vim commands that you can use in your
~/.vimrcfile to customize Vim quickly and easily.
- The second looks more deeply at Vimscript as a programming language, covering things like variables, comparisons, and functions.
- The third walks through the creation of a sample plugin intended for distribution to other Vim users.“
Detect the encoding of a text file:
$ file all.txt all.txt: ISO-8859 text
Get more verbosity:
$ file --mime all.txt all.txt: text/plain; charset=iso-8859-1
Change the encoding of a text file:
iconv --from-code=UTF-8 --to-code=ISO-8859-2 file.txt >tmp.txt
This latter tip is from here.
You can also use “
chardet” for detecting charcter encoding. Usage:
$ chardet test.txt test.txt: utf-8 (confidence: 0.99)
vim has also an excellent detector. If you open a file in vim and it looks good, check out what encoding is being used by vim:
Here is my VIM config file: download. I didn’t paste it here since it’s quite long and contains some special characters. After download you will have to rename it; in the header of the file it is explained.