Emacs : CU (79) #
» a pretty 79 character length divider
VIM : 79-i-#
» see above
Textmate : ????
Or is it just assumed that we'll make a Ruby call or have a snippet somewhere?
I would create a bundle command to do this.
You can take editor selection as input to your script, then replace it with the result of execution. This command, for example, will take a selected number and print the character '#' that number of times.
python -c "print '#' * $TM_SELECTED_TEXT"
Of course this example doesn't allow you to specify the character, but it gives you an idea of what's possible.
Inspired by the other answers. Make a snippet with the following:
`python -c "print ':'.join('$TM_SELECTED_TEXT'.split(':')[:-1]) * int('$TM_SELECTED_TEXT'.split(':')[-1])"`
and optionally assign a key sequence to it, eg CTRL-SHIFT-R
If you type -x:4
, select it, and call the snippet (by it's shortcut for example), you'll get "-xxxx".
You can also use ::4
to obtain "::::".
The string you repeat is enclosed in single quotes, so to repeat ', you have to use \\'.
By taking the
python -c "print '#' * $TM_SELECTED_TEXT"
a step further, you can duplicate the examples you gave in the question.
Just make a snippet, called divider or something, set the tab trigger
field to something appropriate '--'
for example, then enter something like:
`python -c "print '_' * $TM_COLUMNS"`
Then when you type --⇥
(dash dash tab), you should get a divider of the correct width.
True, you've lost some of the terseness that you get from vim, but this is far easier to reuse, and you only have to type it once. You can also use whatever language you like.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.