Sharing: A macro for making text bold () with Ctrl-B
Submitted by Sunday, 18 April, 2010 - 20:19
on
Hi all,
This may be useful for newbies. A macro based on the "Insert Tag" macro which comes with jEdit, but which surrounds the selected text with b and /b tags. I bound it to Ctrl-B and it's a very useful way to quickly make a word bold.
void insertTag(tag) { caret = textArea.getCaretPosition(); if( tag == null || tag.length() == 0) return; text = textArea.getSelectedText(); if(text == null) text = ""; sb = new StringBuffer(); sb.append("<").append(tag).append(">"); sb.append(text); sb.append("").append(tag).append(">"); textArea.setSelectedText(sb.toString()); //if no selected text, put the caret between the tags if(text.length() == 0) textArea.setCaretPosition(caret + tag.length() + 2); } if(buffer.isReadOnly()) Macros.error(view, "Buffer is read-only."); else insertTag("b");Enjoy