KBD

Keith Devens .com

Saturday, March 20, 2010 Flag waving
Any sufficiently complicated C or Fortran program contains an ad hoc, informally specified, bug-ridden, slow implementation of half of... – Philip Greenspun (Greenspun's Tenth Rule)

jEdit

jEdit (http://jedit.org/) is a programmer's text editor written in Java. It's currently my primary text editor. jEdit was written primarily by Slava Pestov.

  1. Customizations/keyboard shortcuts
    1. Lines
    2. Files/Buffers
    3. Markers
    4. Macros
    5. Search
    6. Program
    7. Other
    8. Keyboard shortcuts/features that I expect *any* editor to have
  2. Color scheme
  3. Plugins
  4. Macro documentation
    1. pre-defined variables
    2. Methods in the Macros class
    3. Automatically imported packages
  5. Macro modifications
    1. cutSelectionOrLine and copySelectionOrLine
    2. insertDate
    3. duplicateLine

Customizations/keyboard shortcuts

Lines

  • Cd: delete line (or all lines on which there is a selection - to do)
  • CSd: duplicate line or selection.
  • CAd: delete to end of line
  • Cj: join lines (should work with selected lines (if they're contiguous), but doesn't. I may have to write a macro, or send a patch to the jEdit developers)
  • CSj: format paragraph (CSj because it's sort of the opposite of joining all the lines together - it's separating them into lines of similar length)
  • Cl: go to line
  • Cx: cut selection or line (macro) - this replaces normal cut
  • Cc: copy selection or line (macro) - this replaces normal copy
  • CA↓: move line down
  • CA↑: move line up
  • A→: indent current line
  • A←: de-indent current line

Files/Buffers

  • F12: switch to most recent buffer
  • CF12: show switch buffer plugin
  • Cs: save file
  • CSs: save all files
  • Cn: new buffer
  • CAn: close buffer
  • C tab: next dirty buffer

Markers

  • CF4: add marker
  • F4: go to next marker
  • SF4: go to previous marker

Macros

  • Cmm: record temporary macro
  • Cms: stop recording (I wish Cmm could do both)
  • A1: run temporary macro
  • Cf: find+replace
  • Cg: find next
  • CSg: find prev
  • C/: incremental search
  • CSf: next char (macro) (like VI's fx)

Program

Cq: quit

Other

  • Cz: undo
  • CSz: redo
  • CSl: lowercase
  • CSu: uppercase
  • Cw: toggle word wrap (I wish it would automatically wrap at the screen width, not at 80 (default) chars - update: the next version (4.3) will allow wrapping at screen width)
  • CAa: insert date

Keyboard shortcuts/features that I expect *any* editor to have

  • C→, C←: move forward/back a "word" (though, "word" tends to be defined slightly differently)
  • END, C-END, HOME, C-HOME: end/beginning of line/document. The Mac doesn't do this
  • Holding down shift when moving the cursor should select
  • Ca: select all
  • Both backspace and shift+backspace should delete the previous character. I never realized this was an issue until I used jEdit and found that it didn't do it.

Color scheme

(Applicable to any editor)

  • Comments: green (italic if possible)
  • keywords/operators: blue
  • built-in functions: red
  • strings: pink
  • variables: some shade of brown

Plugins

  • SwitchBuffer
  • FTP
  • BufferList
  • Console
  • JDiff
  • TextTools
  • FindFile

Macro documentation

pre-defined variables

http://www.jedit.org/42docs/users-guide/predefined-variables.html

  • buffer
  • view
  • editPane
  • textArea
  • wm
  • scriptPath
  • For a single-execution macro:
    • line - current line number from start of buffer (0-based)
    • index - current line number from start of selection (0-based)
    • text - text of the current line

Methods in the Macros class

  • message(Component comp, String message)
  • error(Component comp, String message)
  • input(Component comp, String prompt)
  • input(Component comp, String prompt, String default)
  • confirm(Component comp, String prompt, int buttons)

Automatically imported packages

java.awt
java.awt.event
java.net
java.util
java.io
java.lang
javax.swing
javax.swing.event
org.gjt.sp.jedit
org.gjt.sp.jedit.browser
org.gjt.sp.jedit.buffer
org.gjt.sp.jedit.gui
org.gjt.sp.jedit.help
org.gjt.sp.jedit.io
org.gjt.sp.jedit.msg
org.gjt.sp.jedit.options
org.gjt.sp.jedit.pluginmgr
org.gjt.sp.jedit.print
org.gjt.sp.jedit.search
org.gjt.sp.jedit.syntax
org.gjt.sp.jedit.textarea
org.gjt.sp.util

Macro modifications

These are modifications I've made to some of the included macros.

cutSelectionOrLine and copySelectionOrLine

The selection lines were replaced with:

textArea.selectLine();
textArea.goToNextCharacter(true);

insertDate

The entire method was replaced with just:

import java.text.SimpleDateFormat;
//http://java.sun.com/j2se/1.4.2/docs/api/java/text/SimpleDateFormat.html
textArea.setSelectedText( //looks like Jan 04, 2005 5:51:43 -0500 (Tue)
    new SimpleDateFormat("MMM dd, yyyy H:mm:ss Z (E)").format(new Date())
);

duplicateLine

Replaced with:

if(buffer.isReadOnly()){         
    Macros.error(view, "This file is read only.");
    return;
}
lines = textArea.getSelectedLines();
c = lines.length;
text = new StringBuffer();
for(int n=0; n<c; n++)
    text.append("\n").append(textArea.getLineText(lines[n]));
offsetline = textArea.getCaretLine();
if(lines[c-1] != offsetline) offsetline--; //be left on the current line
buffer.insert(textArea.getLineEndOffset(offsetline)-1, text.toString());
textArea.goToNextLine(false);

Now it does "duplicate line or selection", not just "duplicate line", and it works with multiple selection, though it's a little dodgy about where it leaves you afterwards. I'm not even sure what the most appropriate behavior is for the new cases, but the behavior is the same for the original case.

Notes for self: what should happen: normal behavior is to copy the current line and leave you on the new line at the same character position. With multiple selection, you should be left on the first of the duplicated lines at the current character position, or if the character position is longer than the first duplicated line, start at position 0 of that line. Alternatively, start at the end, but I think the beginning is more useful.


Page last edited: April 22, 2005 (utc)

Index

A B C D E F G H I J L M N O P R S T U V W X

All pages

A

  1. About
  2. Acno's Energizer
  3. Artificial Intelligence
  4. ASP.NET
  5. Atom

B

  1. Bash
  2. Belief systems
  3. Bookmarklets
  4. Build tools

C

  1. C and C++
  2. C#
  3. C++ Reference
  4. Calvinism
  5. Cars I want to consider
  6. CGI
  7. character sets
  8. Chess
  9. Christian Reconstruction
  10. Christian Resources
  11. Chronicles of Narnia
  12. Color tools
  13. Computer Science
  14. Cornelius Van Til
  15. CSS - Cascading style sheets
  16. CSSTabs

D

  1. Database
  2. Differencing programs
  3. Documentation standards
  4. Downloads
  5. Dualities
  6. Dvorak keyboard

E

  1. E-mail me
  2. Eclipse
  3. Eiffel
  4. Emacs
  5. Evolution
  6. Extension languages

F

  1. File extensions
  2. Firefox
  3. Formation: web form automation library for PHP
  4. Forth

G

  1. Greg Bahnsen
  2. GUI Toolkits
  3. Guns

H

  1. Hex editors

I

  1. Important articles or essays
  2. Installers
  3. Internet radio stations

J

  1. Java
  2. Javascript
  3. jEdit

L

  1. Linux
  2. Lisp
  3. Logical fallacies
  4. Lua

M

  1. Markup
  2. Miscellaneous Links
  3. mod_rewrite
  4. Movie theaters
  5. My comment policy
  6. My essential programs
  7. My resume

N

  1. Namespaces
  2. Naming conventions
  3. New Years 2000
  4. N^2 sort comparison

O

  1. Open Source License
  2. OPML

P

  1. Perl
  2. Philosophy
  3. PHP
  4. PHP Calendar (version 2.3)
  5. PHP XML Library, version 1.2b
  6. Pictures
  7. Postmillenialism
  8. Presuppositionalism
  9. Programming Fonts
  10. Programming languages
  11. Programming Resources
  12. Punta Cana
  13. Python

R

  1. RDF
  2. REBOL
  3. Reflex game
  4. Regular expressions
  5. Religion
  6. RFCs
  7. Robot Exclusions
  8. Roman Catholicism
  9. Ruby

S

  1. Scala programming language
  2. Science
  3. Shorthand
  4. Skydiving, August 28, 2000
  5. Software I've written
  6. SPAM
  7. SQLite
  8. StructuredText

T

  1. Tabs vs Spaces
  2. Tcl/Tk
  3. Tea
  4. Text Editors
  5. TextDrive
  6. The Big Bang
  7. The naked street
  8. Theonomy
  9. Tools of communication

U

  1. Unicode
  2. URL Design

V

  1. Version control systems
  2. VI text editor
  3. Virtual machines

W

  1. WeblogUrls
  2. Wiki
  3. WikiBlogIntegration
  4. World of Warcraft
  5. wxWidgets

X

  1. XHTML
  2. XML
  3. XML to PHP translator
  4. XML-RPC
  5. XML-RPC Library for PHP (v 2.5)

Generated in about 0.055s.

(Used 4 db queries)