Sublime Forum

How to underline text?

#1

I’m duplicating some of my vim key mappings, such as the one below. I just place the cursor on a line of text and press ctrl-U and it is underlined. I’ve been searching and cannot find a comparable Sublime solution.

-Thanks

"Underline text
map yypVr-

0 Likes

#2

You want to underline code? What for?

I’m not sure you can do this in Sublime Text…

0 Likes

#3

The vim binding duplicates the line and replaces all characters with a -

One way to do this in Sublime would be with this plugin:

import sublime
import sublime_plugin


class UnderlineCommand(sublime_plugin.TextCommand):

    def run(self, edit):
        for r in self.view.sel():
            full_line = self.view.full_line(r)
            line = self.view.line(r)
            self.view.insert(edit, full_line.b, '-' * line.size() + '\n')

Place this code in a file named underline.py in your Packages/User directory (menu Preferences -> Browse Packages, then go into User directory).

Then add this to your User keybindings (menu Preferences -> Key Bindings):

{ "keys": ["ctrl+u"], "command": "underline" },
1 Like

#4

I was just interested in underlining text in a plain text file. domie provided a plugin which I intend to try.

-Thanks

0 Likes

#5

Thanks you, that works perfectly!

0 Likes

#6

How, ok, I didn’t understood what you meant.

If you’re using the vintage package, here’s how you could do it (in command mode):

yypVr{symbol}

So, for example yypVr-

0 Likes