Asked  7 Months ago    Answers:  5   Viewed   42 times

I've added some simple inoremap commands to my .vimrc to help with parens and brackets completion, but I only want them to apply to php files.

 inoremap ( ()<Esc>i
 inoremap { {<CR>}<Esc>ko
 inoremap <? <?php ?><Esc><Left>i

How to I set these commands to be active only when I'm editing a .php file?



Use autocmd FileType:

autocmd FileType php,c,java inoremap ( ()<Esc>i
Wednesday, March 31, 2021
answered 7 Months ago

Apparently in my DbConnect class my PHPDoc comments stated that I was returning 'database' when in fact I was returning a 'mysqli' datatype. This was what was causing the error. The simply fix to this problem was to change be PHPDoc annotation to 'mysqli' and the code completions started to work again.

Saturday, May 29, 2021
answered 5 Months ago

I figured it out, leaving as an example in case someone tries this in the future:

If I want to match column "n", I just need to match anything of column "n-1" and then do my criteria for column n. The following expression finds all lines that have column 35 not equal to space.

^.{34}[^ ]
Saturday, August 14, 2021
Vamsi Emani
answered 2 Months ago

Vimcasts has a useful screencast on this subject that you may be interested in


gg => go to start of file
=  => apply autoformatting
G  => ... to the end of file
Saturday, September 4, 2021
answered 2 Months ago

It's possible, but most people don't.

vim is a fairly generic editor, that said, it does contain some "code completion" features such as word completion, etcetera, but nothing like the likes of, say, Delphi's IDE.

Such a system could be added by scripting vim - vim can directly run several scripting languages that make this easy, or you could send the file through an external script.

Thursday, September 16, 2021
Boudewijn Smit
answered 1 Month ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :