code_complete icon indicating copy to clipboard operation
code_complete copied to clipboard

My Snippits Configuration Problem

Open qSeven opened this issue 14 years ago • 1 comments

Hello Sorry If this is bad style this is really the first time I'm using git/vim scripts

but I was having trouble using the my Snippits to generate my own templates. I found that if I extended any of the current file type templates: '_','cpp','c' it worked fine by when I tried to add my own file type it didn't work. I looked through the code a little and noticed that the expand template function references a variable ft to determine if the opened file has a template associated with it but the ft wasn't referenced any where else in the code so I'm guessing the error has to do with the ft variable.

A quick hack I did to fix this for my self was to add an extra if statement like so:

if has_key(g:template['py'],a:cword)
    let s:jumppos = line('.')
    return "\<c-w>" . g:template['py'][a:cword]
endif

and then I could get my templates working for python files. I know its bad style to hardcode it like this but I haven't read vim script before so that was my best bet to trying to fix this problem.

Good luck!

qSeven avatar Nov 20 '12 23:11 qSeven

The 'ft' variable is a pre-defined variable which will be set to corresponding file type when you open a new file. Try

:echo &ft

and you will see the actual file type of you .py scripts is 'python' not 'py'. So, move your templates to ['python'] probably will do the trick.

mbbill avatar Nov 22 '12 02:11 mbbill