2

I'm doing a "autocmd BufNewFile" for my php class file in my .vimrc. I need to implement standard method, and I want to write them in one line. Here is my probleme, when I press 'o' to begin a newline after a oneline function, I get an "extra tab" who ruins my identation.

    // "one line" example
    Class Example {                                    // 0 tab
        function foo() {return ('foo');}               //1 tab
            function fuu(){}                           //2 tab, I want 1 ofc.
    }

    // discusting example without bug
    Class Example {                                   // 0 tab
        function foo() {return ('foo');               // 1 tab
        }                                             // 1 tab
        function fuu(){}                              // 1 tab
    }

Does anyone got an idea to make this work as exepected?

Here is the interesting part of my .vimrc

    set tabstop=4
    set softtabstop=0 noexpandtab
    set shiftwidth=4
    set term=xterm-256color
    syntax on
    set nowrap
    set mouse=a
    set ruler
    set colorcolumn=80
    set showmatch
    set list
    " Showing tab
    set listchars=tab:>-,trail:-
    highlight SpecialKey guifg=grey ctermfg=darkgrey


    set nocompatible
    set number

    "Better command completion
    set wildmenu
    set wildmode=list:longest
Hugo Hismans
  • 173
  • 1
  • 1
  • 8
  • 1
    Have you enabled autoindent? Try enabling it with `:se ai` and see if it improves things. – Gautam Apr 12 '17 at 10:54
  • Sorry I just notice that my problem is more.. mystic. I thought that was a strange "stable" bug, but no, it just ident randomly one or two tab after the one line function... maybe a weird plugin or something, i'll find some fix by myself. Thanks anyway! – Hugo Hismans Apr 12 '17 at 12:27

1 Answers1

0

This issue looks related to this.

If set ft=html or set ft=phtml doesn't solve your problem, you should consider trying out one of those plugins: http://www.vim.org/scripts/script.php?script_id=604 or https://github.com/2072/PHP-Indenting-for-VIm

Community
  • 1
  • 1
cfz42
  • 384
  • 1
  • 14