Housekeeping

So far, we've had our plugin all within one file. Let's see how we can break it down into multiple files to keep our newly created project organized! Give a look at the list in Plugin layout section of this chapter.

First, you can see that the ftplugin/ directory contains filetype-specific plugin configuration. Right now, most of our plugin is actually pretty independent from working with Python, except for the s:comment_string variable. Let's move it out to <...>/vim-commenter/ftplugin/python.vim:

" String representing inline Python comments.let g:commenter#comment_str = '# '

We've changed the scope from s: to g: (since the variable is now used in different scripts), and added the commenter# namespace to avoid namespace collision. ...

Get Mastering Vim now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.