set nofoldenable not working in my vim - why? - vim

Every time I open one of my markdown (.md extension) files in my MacVim, they automatically fold lots of lines, which is a pathetically frustrating feature in almost all cases. And even after I added set nofoldenable in my ~/.vimrc, it doesn't disable the feature at all. Writing in ~/.gvimrc doesn't work, either.
So is it feasible to disable it? And what am I missing?
I also wonder why the depressing folding feature only functions in my markdown files. As far as I know, all the other extension I use don't conform to the functionality.
I use OS-X default Vim 7.3 and Mavericks 10.9.1.

Have you tried with
au FileType markdown setlocal nofoldenable

Related

vim: enabling Linux coding style per file

I enabled Linux coding style in $HOME/.vimrc as:
let g:linuxsty_patterns = [ '/home/mark/sample1', '/home/mark/sample2', '/home/mark/sample3' ]
But is it possible to enable it per file? As I know, it is possible to pass vim settings in comments in C files. Also, I tried to manually set linuxsty_patterns while editing opened file in vim, but it didn't take any effect.
What am I doing wrong?
You should have stated that your question relates to a specific plugin.
Those questions are better addressed directly to the plugin maintainer.
Now, reading its source code, it seems you just need to specific a list of regexes that match the source files to which you which to apply the plugin setting. It seems this is the only control you could expect with this plugin.
I don't see file types in your example, but I use autogroup like this.
augroup go
autocmd!
" Write file before :make, :GoBuild, :GoTest|Func, :GoRun
autocmd FileType go set autowrite
" go fmt uses tabs for indentation, ts and sw only affect viewer
autocmd FileType go setlocal noexpandtab tabstop=4 shiftwidth=4
" Enable Vim syntax highlighting for Go template files
......
augroup END

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.

Vim filetype detection does not trigger syntax highlighting

I'm trying to detect Go files in vim. I've set this up normally on other computers but this one is stuck.
:set filetype?
filetype=go
So it knows that it's a go file, but isn't triggering the syntax highlighting.
However,
:set filetype=go
triggers it correctly.
:filetype detect
doesn't work, and reopening the file
:e!
turns syntax highlighting off, even though filetype remains set to "go".
I have
set rtp+=/usr/local/go/misc/vim
filetype plugin indent on
syntax on
in my .vimrc (as the instructions say).
What's going on? I suspect there's some other configuration that's undoing the syntax highlighting, but lack the knowledge of where to find it.
I'm not sure exactly what the problem is… However, you can try :scriptnames to see what files were loaded by Vim.
One step further, you can set verbose=9 in your .vimrc and restart Vim. Careful, this is really verbose, try to tweak that number down.

How to enable go.vim by default (automatically)?

The instructions on the Vim site says to just put the file in the /syntax folder. This works all right and well. But, for me to use the syntax I must set the following
:set syntax=go
Every single time. So, I know I am doing something wrong. I just don't know what.
Here are some things from looking around,
My HTML5 syntax set is from Rodrigo's HTML5 omnicomplete function and syntax vimball file. Though this uses some installation script to get it going.
As far as I can tell this would be my first manual adding of syntax file.
Also, my VIMRUNTIME is not set, well because there is no syntax.vim file, so from reading the documentation I see it checks for files via synload.vim
I even read the "Making Your Own Syntax Files" section, which says that same as above with the syntax=go option. Am I supposed to be detecting the .go filetype as described in new filetype section?
How can I enable syntax highlighting for GO by default?
This is for Mac Snow Leopard.
I don't think it is this complicated but I decided to leave all the different documentation I skimmed. GO and Vim say to just add the file. But it is definitely not detecting it automatically
If you are using filetype detection in your ~/.vimrc file with the following line:
filetype plugin indent on
then you can place the file in the following folder:
~/.vim/after/ftplugin/go.vim
or for windows
~/vimfiles/...
For the filetype detection to work, would would want the autocmd in a file in the ftdetect folder:
~/.vim/ftdetect/go.vim
and the contents would be:
autocmd BufNewFile,BufReadPost *.go set filetype=go
Use autocmd:
au BufRead,BufNewFile *.go setlocal filetype=go

Vim - indent like Emacs

I use vim (primary so that I can work on plain ssh terminal - still uncomfortable with Emacs non-gui version) but most of my colleagues in the organization use emacs. So using CVS, we face indentation inconsistency issues (tabs becoming spaces, number of tabs/spaces, code layout etc).
Is there a way I can make VIM indent EXACTLY as EMACS. (similar to the default emacs profile my colleagues use).
(Most importantly, I want vim's C++ and TCL indentation schemes to match that of emacs).
regards,
JP
I don't know if there's a way to directly import Emacs indentation settings into vim, but you can probably configure the same behavior in vim itself:
set expandtab will convert tabs to spaces
set autoindent will keep indentation level from previous line
set shiftwidth=4 will affect block indentation with >> and <<
set softtabstop=4 sets the length of soft tab in spaces
set tabstop=8 sets the width of tab character
This is properly explained in vim wiki.
When you need filetype-specific indentation you have two options:
Set autocmd to change indentation on file read and file creation:
au BufRead,BufNewFile *.py,*pyw,*.html,*.js set shiftwidth=4 will set shiftwidth for *.py files.
Configure filetype plugin, create name.vim scripts inside .vim/ftplugin folder for specific file types and set the described variables there. This is also described in proper detail in vim wiki.
Regarding specialized indenting for c++ and TCL there is some special stuff that applies in aditon to all the other setting info that's been suggested. Vim has special indenting rules defined in code for different languages. Some of this is found is found in the /indent directory of the vim installation, where there is a separate file for each filetype. For more information on how this works read the help for 'indentexpr'.
The c indenting -- and I think also the indenting for c++ -- is mostly defined in Vim source-code, and has a zillion options that you can set, plus is specially configurable in c.vim or c++.vim indent file. Read help for 'cindent' and 'c-indenting' for more help on that.
In short, the tcl.vim file controls special indenting for tcl files. If you want to revise how indenting works with tcl you would want to alter the main function in that file. The c/c++ indenting is largely controlled by Vim internals but with lots of different option flags. You can control c/c++ indenting by configuring the options the way you want them and/or by writing a function for the indent file in /indent directory. (I believe there is no c++ file in /indent directory, not sure if c.vim is file to edit there, or whether you need to create new c++.vim file. I think it's the c.vim file that would be used. which is basically an empty shell in standard Vim install, but you can read other *.vim indent files to get the idea of how they work.
Here's as extract of some options concerning indentation from .vimrc:
set expandtab
set tabstop=2
set shiftwidth=2
set autoindent
set smartindent
All options are nicely described in vim help:
:help smartindent
:help autoindent
UPD: also for C-like languages you may consider :help C-indenting

Resources