code formatting - How to fix broken automatic indentation in vim -
i trying use vim 7.2 (on windows xp) automatically indent , format vhdl , matlab code. trying use "gg=g" command. not work properly. code not indented @ all.
to give example, had following source code, indented:
% function based on code_g_generator() function function [v_code] = get_code(n_code_number) % there no need clear persistent variables in function mlock %% initialize internal variables persistent n_fifo_top; if isempty(n_fifo_top) n_fifo_top = 1; end n_memory_size = 4; if n_code_number > 4 c_saved_code_fifo = {-1*ones(1, n_memory_size)}; end
if use "gg=g" command get:
% function based on code_g_generator() function function [v_code] = get_code(n_code_number) % there no need clear persistent variables in function mlock %% initialize internal variables persistent n_fifo_top; if isempty(n_fifo_top) n_fifo_top = 1; end n_memory_size = 4; if n_code_number > 4 c_saved_code_fifo = {-1*ones(1, n_memory_size)}; end
as can see, in example vim incorrectly indents code after first "if" block. other files similar problems (although not on first if block).
for vhdl files similar problems.
i have tried using different combinations of autoindent, smartindent , cindent settings. after going through these forums have made sure "syntax", "filetype", "filetype indent" , "filetype plugin indent" set on. still, not work. also, if "set syntax?" "matlab" matlab files , "vhdl" vhdl files correct. , if "set indentexpr?" "getmatlabindent(v:lnum)" matlab files , "getvhdlindent()" vhdl files.
to try isolate problem (and ensure not due 1 of vim plugins have installed) doing fresh install of vim on different computer (in vim had never been installed before). on computer same sort of problems (that why not think need give .vimrc, if need can upload here too).
any ideas?
see this wiki page explanations of different methods automatic indentation in vim.
on this page can find indent file matlab can use filetype based indenting. here similar 1 vhdl.
Comments
Post a Comment