I'm getting undefined shiftwidth function error when I try to run Autoformat html in vim-autoformat plugin.

AFAIU shiftwidth is a variable, not a function.

Checking plugin's source I see that it invokes it by a certain "s" object:

let g:formatdef_astyle_cs = '"astyle --mode=cs --style=ansi --indent-namespaces -pcH".(&expandtab ? "s".shiftwidth() : "t")'

which I couln't find. Anyone knows how I solve this ?

My VIM version: 7.3.429


shiftwidth() is a function that has been added I think late in the 7.3 circle. Can you update your Vim version?

| improve this answer | |
  • I updated the question with my VIM version. And will try to update to 7.4. – Nelson Teixeira Jan 14 '16 at 17:55
  • 1
    @NelsonTeixeira From :help fixed-7.4: "Patch 7.3.694 [..] Add the shiftwidth() function". So yeah, you need a newer Vim version (path 7.3.694 or higher). – Martin Tournoij Jan 14 '16 at 18:14
  • 7.4 is compiled against a different ruby version. when installed breaks my command-t plugin. I'll try to update to a higher 7.3 branch. – Nelson Teixeira Jan 14 '16 at 18:16
  • 1
    @NelsonTeixeira It sounds to me that fixing Command-T is the way to go, rather than stick with an old version forever ;-) – Martin Tournoij Jan 14 '16 at 18:17
  • 1
    @NelsonTeixeira alternatively, replace every shiftwidth() function call by the shiftwidth option, e.g. this part: ` "s".shiftwidth()` by "s".&sw should also work (needs to be done everywhere). – Christian Brabandt Jan 14 '16 at 21:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.