How to safely paste text into Vim in terminal mode

When Vim is running in terminal mode (at the console) and you paste text (say source code) into it, the pasted text might get crazily indented.

This happens because Vim in terminal mode cannot distinguish between typed text and pasted text. Vim thinks that you had typed in that pasted text and it adds in its automatic indentations to that text. Since that text already has all the necessary indentation, the extra indentation makes it looks crazy.

One way to safely paste text into terminal Vim is to temporarily switch it to paste mode, then paste in the text and then toggle it back to nopaste mode.

You can switch it to paste mode by typing :set paste. You can switch it back by typing :set nopaste

These tricks are not needed for GVim since it can distinguish that the pasted text is coming from outside the application.

Tried with: Vim 7.3

Turn on color prompt in Ubuntu

All the text displayed in the terminal is in the same color in Ubuntu. This makes it hard to distinguish the output from several commands in the terminal. It is nice to have the prompt displayed in a color different from the normal text.

To turn on color for the prompt, open .bashrc and uncomment the following line in it:

force_color_prompt=yes

Restart the terminal and the prompt should be in color now. By default, it seems to be green in color.

Tried with: Ubuntu 12.04

How to plot at terminal using GNUPlot

Gnuplot is an awesome graph plotting program that has been around since the time of dot-matrix printers and teletype terminals. Little wonder that it has support for such archaic output devices even today. One such output terminal supported by Gnuplot is called the dumb terminal.

I find the dumb terminal pretty useful to have around in the initial stages of plotting to get a rough idea of the data. The default terminal on Windows is called wxt and gnuplot pops up a new window to display the plot. If you find that and switching between windows distracting, use the dumb terminal which plots a quaint ASCII-art graph! 🙂

To switch to a dumb terminal:

gnuplot> set terminal dumb

Reference: Page 220 from the book Gnuplot in Action