Neovim Automatically Uses 4 Spaces Instead of Tabs for Python - vim

Title says it all. How can I change this behaviour, so that the indentation is always a tab character and not 4 spaces?
I don't get the same issue when not editing python files.
Not that I edit many different file types, but I can at least confirm for c, plaintext and tex (as in LaTeX).
Using version 0.4.4 from the Gentoo repos.

Try putting let g:python_recommended_style = 0 in your vimrc, and configuring autocmds such as autocmd FileType python setlocal noexpandtab if needed.

Related

Can't use 'mark a' or 'mark A' in vim

I like to use vim (on ms windows), I guess everybody have a favorite editor and this is mine.
On one particular PC I run into problems conserning the mark[a-zA-Z] command.
It does not work for the letters a and A but it does for b-z and B-Z and I would like to know why.
If I use the command :marks I can see that ma and mA do set an entry. But 'a and 'A have no effect. The same for the backtick versions.
If I do the same with labels b or B it works.
I checked my _vimrc but there is no line doing something to a or A.
What can block the labels a and A?
How can I find out what is causing this problem?
Any sugestion is welcome.
Additional information: 5-mar-2016, 23:59
I have no _gvimrc file and use the `standard' _vimrc file, never took the time to dig deep into the vim configurations. So it is still pretty vanilla. I like it this way, there are too many PC's I have to work with and synchronising _vimrc files is not what I'm looking for. :-)
This is in my _vimrc file.
:source C:\Program Files (x86)\Vim\_vimrc
let g:xml_syntax_folding=1
:filetype on
:filetype plugin on
:set foldmethod=marker
:set foldmarker={,}
autocmd FileType xml source C:\Users\andre\vimfiles\ftplugin\xml.vim
autocmd FileType python source C:\Users\andre\vimfiles\ftplugin\py.vim
autocmd FileType cs source C:\Users\andre\vimfiles\ftplugin\cs.vim
I have tried the suggestions made by cbaumhardt and that does not make any difference, running vim -Nu NONE -U NONE.
Additional information: 6-mar-2016, 20:23LT
The keyboard setting was interfering with the input. (US-international)
Changing the keyboard setting to US solved the problem.
The operating system can intercept the key presses before vim sees it. So if you use an international keyboard layout, 'a might produce a with an accent. Vim will not see 'a which is why the mark doesn't work.
One solution is to map the character with the accent to 'a or change the keyboard layout.
nnoremap <a with accent> 'a

auto-formating tool for django html template files

Is there a *nix tool (or vim plug-in) that would allow me to automatically format django html template files?
Hitting the space bar hundreds of time does not sound like a good use of my time but then neither does leaving some weird formatting that is hard to read.
Install vim-jinja2-syntax plugin by putting Glench/Vim-Jinja2-Syntax when installing it with plugin manager (vim-plug, Vundle etc.)
Put autocmd FileType html setlocal expandtab shiftwidth=2 tabstop=2 in the vim config file, which is usually at ~/.vimrc.
run gg=G in django html file(aka jinja template)
vim has a filter for fixing indentation (I think that's what you mean with "auto-formatting"): =. If you wan to indent the whole django html template file, just type gg=G and that will do the job. gg tells vim to go the the first line, = to indent and finally G to got to the end of the file.
You can read more about this on vim docs.

LaTeX code was abbreviatedly displaied by Vimwiki in Vim

My GVim distribution on a Windows 8.1 machine has both vimwiki and Vim-Latex-Suite installed through Vundle.
It bothers me that the following display (on the left) will occur when I do the following:
Open a *.wiki file (thereby enter the filetype vimwiki once);
In the same GVim session, open another *.tex file.
Notice that almost all those math symbols are no longer readable on the left. The quoted code-segment was displayed correctly (on the right) when opened by itself, through a new Gvim.exe session.
For this specific case, my guess is that, Vim is incapable of:
Correctly identify and display all math symbols (e.g. subscripts are displayed as a square);
Correctly displaying math symbols in full-width. (By default, half-width is default and this is why those \phi or \int are hiding all its right part.)
The goal for this post is not to "display math symbols in Vim" correctly. It is too wild and LyX can handle it pretty well. Instead, I would like to know:
How can I stop Vimwiki from interfering the display of *.tex
documents?
Any suggestion? Thank you in advance :)
Original answer from #Sato Katsura
This is the conceal feature. It works better in gVim, provided that you use a font that has all the relevant symbols. You can disable it with:
set conceallevel=0
Further details for Vimwiki
Vimwiki has specified g:vimwiki_conceallevel=2 by default according to line 2100 of the help file. Unfortunately, this "default value" was set globally for all buffers.
Specific solution:
For ~\vimfiles\ftplugin\tex.vim, add the following to the end:
setlocal conceallevel=0
For ~\vimfiles\ftplugin\vimwiki.vim, add the following to the end:
setlocal conceallevel=2
I've had the same problem what made me research until reach this mapping:
nnoremap <Leader>c :let &cole=(&cole == 2) ? 0 : 2 <bar> echo 'conceallevel ' . &cole <CR>
It toggles between conceallevel=0 to conceallevel=2

Why does VIM changes encoding of all buffers when using setlocal?

When I'm using setlocal encoding on VIM to change the buffer encoding VIM changes the encoding of all buffers. It's really annoying because I'm editing files in different encoding and I'm corrupting them all the time. I tried it by creating two buffers, did a setlocal encoding=latin1 on one, a setlocal encoding=utf-8 on the other : the encoding is always the same on the two buffers and it's always the last encoding I set.
setlocal works well on 'shiftwidth' for example, the issue only exhibits on the encoding option.
I tried to reinstall a new copy of VIM, I tried the 7.2 and 7.1, I still have the issue. I've disabled all my plugins, my vimrc.
Am I losing my mind thinking that it's the way it used to work ? Do you have some idea that might cause that ?
I'm using VIM on Windows 7 if that's important.
'encoding' is a global option that dictates how Vim treats text internally so you are two times wrong.
setlocal doesn't work for global-only options like 'encoding'.
:help 'option' tells you the "scope" of 'option'.
'encoding' is not the option you are looking for, you want :set fileencoding=utf-8.
Reference:
:help 'encoding'
:help 'fileencoding'
:help 'setlocal'

Enabling markdown highlighting in Vim

I'm using Vim in a terminal on my MacBook Air with OS X Lion, and I can't seem to find a good plugin for Markdown syntax highlighting.
So far I've tried the plasticboy plugin and Tim Pope's plugin. The plasticboy plugin worked OK but was causing white space at the end of lines to be highlighted, and I haven't figured out how to turn that off. (It's really annoying, because every time I hit space when I'm writing it highlights the character.)
Tim's plugin didn't seem to do very much in the way of highlighting, other than maybe headers that use ###. Code blocks and bullets are ignored. I might be missing something there. I do use the .md extension on my Markdown files, so it should be picking up the filetype.
I've also seen a reference to Vim 7.3 having Markdown support built in, but without one of those two plugins I don't get any highlighting at all.
Do either of these require specific color schemes to work?
About the native syntax highlight for markdown I think it only works for files with the extension .markdown by default.
I was having problems with markdown syntax highlight for my .md files.
I tried:
:set syntax=markdown
And it worked.
So i included the following line in my .vimrc:
au BufNewFile,BufFilePre,BufRead *.md set filetype=markdown
Now my vim have syntax highlight for my .md files.
BufFilePre is needed for :sav
Native syntax highlighting
Native syntax highlighting for Markdown only works by default for the .markdown file extension.
The following line in .vimrc yields the best results for both vim and gvim:
autocmd BufNewFile,BufFilePre,BufRead *.md set filetype=markdown.pandoc
Explanation:
1. Specify your Markdown flavour!
If you work with mainly one flavour of Markdown (e.g. Pandoc), be sure to mention this as well! Doing so, allows for mixing and matching of both Markdown- and Pandoc-specific Vim plug-ins. For example: I have found the vim-pandoc-syntax plug-in particularly suitable for my highlighting needs. Nevertheless, I use the more general vim-markdown-folding for Markdown folding.
By the way, only one flavour is allowed, separated by a dot, e.g.: filetype=markdown.pandoc
2. gvim requires BufFilePre
gvim requires an additional BufFilePre in the autocommand line for Markdown file type recognition with the Save As… :sav command.
This should work to disable the end-of-line space highlighting when using the plasticboy mkd plugin:
:syn clear mkdLineBreak
You could autocmd that for the necessary file extensions so that you needn't do it every time you load a markdown file.
Note that this specific highlight exists because Markdown treats lines ending with 2 or more space characters specially by inserting a <br>, so it is useful.
The plasticboy plugin uses TODO highlighting for this rule, which is a bit too much as it's designed to, by default, be really garish - yellow background - so that it stands out. You can make this less visually striking by changing that highlight rule. One quick way to do this would be something like:
:hi link mkdLineBreak Underlined
Now those end-of-line spaces will show up as underlined. Try linking to other highlight groups for something that may appeal to you more. Instead of using link you can get even more specific about those end-of-line spaces: for instance you could specify that they show up as just slightly lighter/darker than the normal background, using your own highlight command, specifying custom ctermfg, ctermbg, guifg, guibg settings.
As above, you could autocmd this to apply your specific settings.
For more information about link highlight groups, type: :help group-name and you'll see a list of groups that can be linked that themselves should helpfully be displayed using their current highlight rules. Also: :help highlight.
In Tim's plugin the .md extension works only for README.md because filetype.vim specifies so.
" Markdown
au BufNewFile,BufRead *.markdown,*.mdown,*.mkd,*.mkdn,README.md setf markdown
If you don't like putting all of your configuration in ~/.vimrc, you can create ~/.vim/ftdetect/markdown.md (or its equivalent on Windows) with the following contents.
au BufNewFile,BufRead *.md setf markdown

Resources