Show line numbers in vi

To show lines numbers in vi, use the following command:

:set nu

To hide them again:

:set nu!

The commands only affect the current document. To always show line numbers in vi you have to add the following line to ~/.vimrc:

set nu

jQuery: textarea content losing line breaks on update.

If you’re updating a textarea’s content using jQuery, you might understandably use the text(var) method, thinking that you are updating the text content of an HTML element.

However, on Internet Explorer at least, you’ll lose the line breaks, although they are present in var.

To preserve the line breaks, use the val(var) method to update the textarea – jQuery realises that the HTML element is a textarea, not an input, and updates the content accordingly.