> but, i just want to make a shell of inner-command"function", to make a > user-defined-sub-script. > e.g. maybe you can write a script: > BeginFileType 'c' > AddAbbrev "main", "main()\<cr>{\<cr>}\<cr>" > EndFileType > > and, in my script, i will > command! -nargs=1 BeginFileType if &ft == <args> > command! -nargs=0 EndFileType endif > command! -nargs=+ AddAbbrev call s:add_abbrev(<args>) > runtime yourscript.template > delcommand BeginFileType > delcommand EndFileType > > how can i make it?
Looks like you actually want an autocommand. A configuration something like this is fairly standard: :augroup MyFileTypeSettings :au! :au FileType c call MyCSettings() :augroup END :func! MyCSettings() : " Add your abbreviations, etc. :endfunc The :au! command clears all the autocommands in that group, so leave it out if you don't want it. Another possibility is putting the stuff you want for C in ~/.vim/ftplugin/c.vim (make the directories if they don't exist) and they will automatically be loaded as long as filetype plugins are turned on. If you prefer, you can pretend it's syntax or indent, e.g. ~/.vim/syntax/c.vim and it will load for C as long as you have syntax highlighting turned on (and filetype detection). If you need to override things in the default Vim setup, you may need to use ~/.vim/after/ftplugin/c.vim instead (or similar). And if you're on Windows, it's $HOME\vimfiles not ~/.vim by default. Anyway, these are the two standard ways to add filetype-specific settings. Hope this helps! Ben. --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---