Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Underline the current line in vim

Answer:

Underline the current editing line in vim is very useful, to do so, follow the guide below.

1. Press [ESC] to get into command mode

2. Enter :set cursorline

Set filename in terminal title in vim

Answer:

To display the currently editing filename in the title of terminal of vim, you can try the tricks below:

1. Press [ESC] to get into command mode

2. Enter :set title

Display non-printable character in vim

Answer:

To display non-printable characters, such as control characters in vim, you can try the tricks below:

1. Press [ESC] to get into command mode

2. Enter :set list

If you want to turn off the non-printable character, enter :set nolist will revert the option set above.

How do I find and replace non-printable characters in vim?

Answer:

To replace non-printable characters in vim, e.g. get rid of ^M, you need to use the following replace method.

:%s/^M//g

Notes: The ^M above was inputted by holding down "Ctrl+v+m" at the same time.

Open UTF8 file with Vim

Answer:

If you opened an UTF-8 file, you need to let vim know by using the command below, after entering the command mode by pressing Esc + :

: set encoding=utf8