When I write .f90 or .f file I have the problem that vim always highlight the first number of empty columns with red See figure. I have tried to use :noh but did not work. If I use "set list" they disappear but then a lots of symbols appear.
My vimrc file can be see here
Tab isn't part of the Fortran character set, so a properly formatted Fortran source file shouldn't contain tabs. You might want to configure vim to replace tabs with spaces.
Related
I would like to get Vim to stop highlighting list characters (-,*) and heading characters (#) in rmarkdown. You can find a screenshot here: https://imgur.com/a/0YSB8V8.
This is happening when I set the file type to either pandoc or rmd. This is also happening no matter what terminal or colortheme I use.
I have the plugins: vim-pandoc, vim-pandoc-syntax, and vim-rmarkdown installed.
I would like to know a way to make the two characters just appear normally.
I would also like to know if there is a way to make italicized text in tables and headings appear italicized. As far as modifying the appearance of italicized text, I've tried using: hi Italic ctermfg=red cterm=italic in my vimrc, but that does not seem to affect the text in between asterisks (*) in rmd files. I admit I don't know much about the way that syntax works in Vim. Do I need to modify after/ftplugin/rmd.vim or runtime/syntax/rmd.vim? What is the difference between the two?
Any help would be appreciated!
Your syntax highlighter does not seem to recognize the bullet points, but thinks that they mark the beginning of an italic span. Maybe you have a clash of plugins. You could also try another highlighter (e.g. vim-polyglot, supports italics).
vim-pandoc-syntax uses the conceal feature (:h conceal). You can recolor the highlighting group Conceal to change the appearance of the replacement characters.
You can put changes to existing syntax files in .vim/after/syntax/rmd.vim. Files in syntax are executed when they are needed for the first time, but at most once per session. Files in ftplugin are executed every time the file type is changed.
I have tabstop=4 and expandtab set in my vimrc. Is there a way of making Vim automatically set the tab width value based on what is used in the file that is currently being edited, or do I have to set it manually each time I edit something that doesn't use 4 spaces per tab?
You can try vim-sleuth.
This plugin automatically adjusts 'shiftwidth' and 'expandtab' heuristically based on the current file, or, in the case the current file is new, blank, or otherwise insufficient, by looking at other files of the same type in the current and parent directories. In lieu of adjusting 'softtabstop', 'smarttab' is enabled.
Another plugin, YAIFA
This plug-in will automatically try to detect the kind of indentation in your file and set Vim's options to keep it that way. It recognizes three types of indentation:
1.- Space: Only spaces are used to indent.
2.- Tab: Only tabs are used.
3.- Mixed: A combination of tabs and space is used. e.g.: a tab stands for 8 spaces, but each indentation level is 4 spaces.
The values of 'expandtab' and 'shiftwidth' set in your vimrc will be used as the default values.
It works like a charm.
autotab.c analyzes an up to 5000 line sample of a file to determine the expandtab, tabstop and shiftwidth parameters.
It uses a fairly elaborate algorithm which actually renders the sample using different tab sizes to figure out which one produces the nicest line-over-line alignment based on various heuristics.
Written in C, it's very fast (no noticeable delay when loading a file) and has no dependencies other than a few functions in the standard C library.
In C++ files that I edit with Gvim I have noticed that code lines which are in inside blocks
(curly braces {})
although are being shown on the screen with the correct amount of tabs in Gvim
(i.e. plus one tab from the code which is outside of this code block)
when I open the same files with an another editor
like sublime text
that extra tab that must exist in every line inside the code block does not exist.
So after opening these files with a hex editor I noticed that Gvim does not write those extra tabs in the code blocks?
Why does this happen?
Is it because of cindent?
Also how can I fix this rather than auto-reformat every time?
I am pretty sure that vim will faithfully save all the characters that are in the buffer. Various options affect how tabs are displayed, and whether actual tab characters or spaces are used for indenting. You can check their values, and see where they were set (default, in your vimrc file, or by some plugin) with
:verbose set ts? sts? et? sw? sta? ci? pi?
(These and more related options are grouped together if you open an options window with :options and look at Section 15.) If you want to visually check where you have tab characters rather than spaces, you can :set hls and then search for tab characters (or :match Search '\t') or you can :set list.
If you try all that and you still think that vim is not saving what is in the buffer, then there are odd things to check, like whether you have any BufWrite or related autocommands.
I have a javascript file that I created in Vim and it looks fine, but when I open it in another program such as just a text editor, the indentations are much greater (like 10 times the space) and some lines are misaligned. The only thing I have relating to lines in my ~/.vimrc file are:
"set tab indentation to 2 spaces"
:set tabstop=2
filetype plugin indent on
Has anyone seen this behavior or know what could be the issue?
Your vimrc file is configured to show tabs as 2 spaces, but the way tabs are shown isn't the same in every program. Sometimes they're shown as 4, sometimes 8. A typical argument is to use multiple spaces instead of actual tabs, to make the file look consistent regardless of the text editor's tab settings, but at the cost of increased file size. A search for "tabs vs spaces" will yield plenty of arguments for both sides.
If you decide to use spaces, you could, for example, configure vim to insert spaces whenever you press the tab key:
:set tabstop=2
:set shiftwidth=2
:set expandtab
(from vim wiki)
The default tab spacing in many text editors is 8 spaces, not 2, so the indentations for any source code that contains tabs will appear much greater in those text editors.
This has bugged me for a long time, and try as I might I can't find a way round it.
When I'm editing text (specifically latex, but that doesn't matter) files, I want it to auto-wrap at 80 columns. It does this, except if I happen to be in the middle of a parenthetical clause, it indents the text which is very annoying. For example, this works fine
Here is some text... over
two lines.
but this doesn't
Here is some text... (over
two
lines
If anyone can tell me how to turn this off (just for text/latex files) I'd be really grateful. Presumably it has something to do with the fact that this is desired behaviour in C, but I still can't figure out what's wrong.
:set nocindent
The other options do nothing, and the filetype detection doesn't change it.
There are three options you may need to turn off: set noai, set nosi, and setnocin (autoindent, smartindent, and cindent).
This may be related, when pasting from gui into terminal window, vim cannot distinguish paste modes, so to stop any odd things from occuring:
set paste
then paste text
set nopaste
I had similar issues trying to paste xml text, it would just keep indenting. :)
gvim, the gui version of vim, can detect paste modes.
You can have a look at the autoindent option :
autoindent - ai
Copy indent from current line when starting a new line (typing
in Insert mode or when using the "o" or "O" command). If you do not
type anything on the new line except and then type or
, the indent is deleted again. When autoindent is on,
formatting (with the "gq" command or when you reach 'textwidth' in
Insert mode) uses the indentation of the first line. When
'smartindent' or 'cindent' is on the indent is changed in specific
cases. The 'autoindent' option is reset when the 'paste' option is
set. {small difference from Vi: After the indent is deleted when
typing or , the cursor position when moving up or down is
after the deleted indent; Vi puts the cursor somewhere in the deleted
indent}.
From the official Vim documentation
filetype plugin indent on
This switches on three very clever
mechanisms:
Filetype detection. Whenever you start editing a file, Vim will try to
figure out what kind of file this
is. When you edit "main.c", Vim will
see the ".c" extension and
recognize this as a "c" filetype.
When you edit a file that starts with
"#!/bin/sh", Vim will recognize it as
a "sh" filetype. The filetype
detection is used for syntax
highlighting and the other two
items below. See |filetypes|.
Using filetype plugin files Many different filetypes are edited with
different options. For example,
when you edit a "c" file, it's very
useful to set the 'cindent' option to
automatically indent the lines. These
commonly useful option settings are
included with Vim in filetype plugins.
You can also add your own, see
|write-filetype-plugin|.
Using indent files When editing programs, the indent of a line can
often be computed automatically.
Vim comes with these indent rules for
a number of filetypes. See
|:filetype-indent-on| and
'indentexpr'.
:set noai
sets no auto indent tt may be smartindent though. Check out the doc and see if you can find something more
http://www.vim.org/htmldoc/indent.html