Comments (8)
I agree, this would be nice. And I will try to add this at the weekend. I can probably do it really fast, so there is no need for you to do it yourself.
Would you really cut of the text, or just let it use more space in case the inserted text is longer?
Eg.
/*-------------------------------------------------------*/
/* name: |NAME--------------| <-- COOL NAME */
Would result in (as it should) [Example 1]:
/*--------------------------------------------------------*/
/* name: Morgan Stanley <-- COOL NAME */
Which is really useful and therefore should be included. But if the name is to long [Example 2],
/*--------------------------------------------------------*/
/* name: Really Long Name of a Dude <-- COOL NAME */
it would actually break the format (on purpose, see below).
Compare C's sprintf. The format specifier would also completely display text, even if it is longer than 20 characters:
sprintf(buf, "%20s some further text", text);
This is a question of design philosophy. In designing all of this, my approach is that editing stuff is easier than adding new stuff. So I would rather break the format and insert the full name, seeing how this would be easy to fix. Secondly, if it breaks the format, that's easy to spot, while an incompletely inserted variable name, date, ... would be much harder to notice at a glance. You would of course still get the benefit of all the cases where it works correctly, which would hopefully be the vast majority of cases.
So I really like your suggestion, I'm just unsure about the "exception handling". What do you think?
from vim-plugins.
By exceptions do you mean text expanded which would be larger than specified macro?
Were it possible, in those cases, symbols like '|' or '-' could be used after the first '|' in the macro expansion to specify whether the expanded text should be cutoff. If one of those symbols were included then it would cutoff the text else it would just proceed as normal expanding the whole text even if it pushed the rest of the line further.
For example without '-':
/*--------------------------------------------------------*/
/* name: |NAME----------| <-- COOL NAME */
Would expand to ->
/*--------------------------------------------------------*/
/* name: Really Long name of Dude <-- COOL NAME */
And with '-':
/*--------------------------------------------------------*/
/* name: |-NAME----------| <-- COOL NAME */
Would expand to ->
/*--------------------------------------------------------*/
/* name: Really Long name <-- COOL NAME */
I think one can also cutoff text with C's sprintf by adding '.20' after the '20' to make the string no longer than 20 characters, but also occupy 20 characters if less characters are specified by text.
sprintf(buf, "%20.20s some further text", text);
I don't want to push any work on you, because I don't know how difficult it would be to implement this in your code, or whether this would break syntax or other stuff. But I think this is how I would change this.
Thanks for replying 👍
PS: You are right that date, times and those types would be difficult to debug if they were cutoff
from vim-plugins.
Is in the works. I'll push tomorrow.
from vim-plugins.
I've pushed a version of the format specifiers:
1a7cfed
See the documentation:
https://github.com/WolfgangMehner/vim-plugins/blob/master/doc/templatesupport.txt
Look for section
4.1.3 Format Specifiers
from vim-plugins.
Your template now could look like this:
/*--------------------------------------------------------*/
/* name: |NAME%----------| <-- COOL NAME */
/* comment: <RCURSOR> */
/*--------------------------------------------------------*/
from vim-plugins.
Nice, I just read the documentation. I will try your changes this afternoon. The changes on the documentation look awesome 😃
from vim-plugins.
Thanks! Your new changes are awesome 😄 I will keep on testing them and will let you know of anything I find. But your changes exceeded my expectations. Thank you so much
from vim-plugins.
Your welcome.
I plan to release the plug-ins with the new template version after Christmas. Until then the behavior may still change. So suggestions (and bug reports) are highly welcome.
That being said, I'm already quiet content with the changes. And they will help me with another extension I planned.
from vim-plugins.
Related Issues (20)
- perl path on windows
- template error message HOT 4
- Add lua support into SpaceVim. HOT 12
- Bash-Support: g:BASH_Ctrl_j = 'off' ignored HOT 3
- C-support: how to integrate c-support into existing vim config HOT 5
- Bash support: broken highlighting on ${var/pat/} HOT 1
- Perl-Support: Extending the Perl/POD templates and menu HOT 2
- C-Support: header and implementation comment interchanged HOT 1
- C-support: How to display output in gVim and not vimrun? (Windows 10) HOT 1
- bash-support: Go to end of file after inserting a new header HOT 6
- c-support: Modified class template ignores filename HOT 2
- c-support: Spacing in template is ignored HOT 2
- Bash-Support: function calls references HOT 5
- Bash-Support: parce call stack on error HOT 8
- Not working here HOT 4
- Bash-support - GVim and templates question HOT 2
- Perl-Support: E488: Trailing characters HOT 7
- C-Support: Change C idiom function return indent HOT 6
- c-support Duplicate Tags HOT 1
- nr cmd vim tips e486 error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vim-plugins.