SmartKeys
From Niki
I have some small macros to add a little each to some popular functions:
Smart Tab
A plain tab works as before, depending on your tab stop settings; Shift-tab would insert a tab character (useful if you usually emulate with spaces). If you select some lines you can change indentation level easily.
define smartTab
{
if ($selection_start == -1)
{
process_tab()
} else
{
shift_right_by_tab()
}
}
define smartUntab
{
if ($selection_start == -1)
{
insert_string("\t")
} else
{
shift_left_by_tab()
}
}
Now there are two problem: One is that you cannot use the GUI to put these macros on the (shifted) tab key. You have to do something which is normally neither necessary nor recommended: Edit nedit.rc by hand.
For that, follow these steps:
- Add the macros above to the macro menu as usual.
- Save your settings.
- Make a backup of your nedit.rc.
- Open your nedit.rc
- Find the menu entry for smartTab().
- After the colon following the menu entry name, enter 'Tab'.
- Find the menu entry for smartUntab().
- After the colon following the menu entry name, enter 'Shift+Tab'.
- Save nedit.rc.
- Leave this NEdit session.
The second problem is that this works only with Lesstif, Motif is buggy here.
Smart Home
This toggles between column 1 and the first non-whitespace position. Put on the Home key for best effect.
define smartHome
{
c = $cursor
beginning_of_line()
if (c == $cursor)
{
set_cursor_pos(search("\\S|\\n", $cursor, "regex"))
}
}
Smart Goto Selected
This extracts the first number from a string and jumps to the line indicates by the number. Very useful for selecting compiler output. Put on Ctrl-e.
define smartGotoSelected
{
if ($n_args != 1)
{
# Wrong number of arguments
beep()
return
}
line = $1
start = search_string(line, "\\d+", 0, "regex")
if (-1 == start)
{
# no valid number found
beep()
return
}
lineNum = substring(line, start, $search_end)
goto_line_number(lineNum)
}
