if (&filetype=='c' || &filetype=='cpp' || &filetype=='h')  autocmd VimEnter * NERDTree  autocmd VimEnter * wincmd p   class outline viewer : F8  nmap <F8> :TagbarToggle<CR>endifI tried this vimrc script, but it is not working.
enable NERDTree only when editing h/c/cpp files
vimrc
Not sure but I think VimEnter is called before &filetype is set so that if is never executed. Try:augroup C    autocmd!    autocmd FileType c,cpp NERDTree | wincmd p | nmap <F8> :TagbarToggle<CR>augroup ENDBetter to write an filetype plugin (see :h ftplugin). For example I have a file in ~/.config/nvim/after/ftplugin/javascript.vim with this content:autocmd BufReadPost,BufWritePost <buffer> Accio eslintautocmd InsertLeave,TextChanged <buffer> call semhl#highlight()autocmd FileType javascript call semhl#highlight()nnoremap <buffer> <C-]> :TernDef<cr>These auto-commands and the mapping are only available for JavaScript files. I don't know how to call an ftplugin for both C and C++, but the content would be something like:autocmd FileType c,cpp NERDTree | wincmd pnmap <buffer> <F8> :TagbarToggle<CR>If you use Vim the location of this file would be ~/.vim/after/ftplugin/c.vim.EditAccording to this answer you can use symbolic links or source your c.vim ftplugin from your cpp.vim plugin (or vice versa).