Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get rid of red highlighting of tab space when editing Fortran in Vim

Tags:

vim

vi

fortran

When I code Fortran, and use tabs for indentation, Vim highlights those spaces in red, because in older Fortran the first 6 columns were special and reserved for labels/line numbers and continuation symbols. How can I make Vim stop doing that?

Thank you.

like image 851
Samuel Tan Avatar asked Dec 21 '11 13:12

Samuel Tan


People also ask

How do I turn off highlighting in vim?

Add the following to your . vimrc: :nnoremap <silent> <CR> :nohlsearch<CR><CR> . Hit return in command mode, and the highlighting disappears.

Why does vim highlight in red?

Similarly, errors are generally highlighted in red color and it looks like vim does not know how the syntax should be handled for /etc/sysconfig/named . However, highlighting of error messages is done with the help of Error and ErrorMsg highlight groups.

How do I edit tabs in vim?

Probably the easiest to remember is to run the :tabnew command while in normal mode. This will open a new tab with an empty buffer. If you want to edit a file in the new tab, you can run :tabnew filename and Vim will load the file in the new tab.

Does vim use tabs or spaces?

There are four main ways to use tabs in Vim: Always keep 'tabstop' at 8, set 'softtabstop' and 'shiftwidth' to 4 (or 3 or whatever you prefer) and use 'noexpandtab'. Then Vim will use a mix of tabs and spaces, but typing and will behave like a tab appears every 4 (or 3) characters.


2 Answers

Actually, tab is not part of the Fortran character set, and portable code should avoid it. So instead I'd recommend to configure vim to use spaces instead of tabs for indentation, see the "expandtab" option.

like image 189
janneb Avatar answered Sep 24 '22 23:09

janneb


stop highlighting Tab

:hi link fortranTab NONE

start highlighting Tab

:hi link fortranTab Error
like image 36
kev Avatar answered Sep 25 '22 23:09

kev