The command
Delete Line is written to delete just the line the caret is placed in without the need to select it. If you want to copy the first 1000 lines, simply select them and copy them to a new file. It is also possible to select everything from line 1001 to end of file and delete those lines, but that would take longer than simply copying the first 1000 lines into a new file.
Manual steps to select the first 1000 lines and copy them.
- Open the file, caret is at top of the file.
- Press Ctrl+G to execute command Search - Goto.
- Enter 1001.
- Press and hold left SHIFT key to not just go to line 1001, but additionally selected everything from current position of the caret to the new position.
- Press RETURN key or click on button Goto while still holding SHIFT key.
- The dialog is closed, the caret is now at start of line 1001 and the first 1000 lines are selected. Press Ctrl+C to copy the selected lines to active clipboard.
- Press Ctrl+N to create a new file.
- Press Ctrl+V to paste the copied lines into this file.
- Press F12 (or Ctrl+S) to save the new file with the first 1000 lines with a name you have to enter
Those few steps executed manually in 5 seconds (if knowing all the hotkeys) as UltraEdit macro (with some additional commands):
IfExtIs "CSV"
InsertMode
ColumnModeOff
TopGotoLineSelect 1001 1Clipboard 9Copy
NewFile
PasteClearClipboard
Clipboard 0SaveAs ""EndIfThe same as script (without using a clipboard because of using a string variable):
- Code: Select all
if (UltraEdit.document.length > 0) {
UltraEdit.insertMode();
UltraEdit.columnModeOff();
UltraEdit.activeDocument.top();
UltraEdit.activeDocument.gotoLineSelect(1001,1);
var sBlock = UltraEdit.activeDocument.selection;
UltraEdit.newFile();
UltraEdit.activeDocument.write(sBlock);
UltraEdit.saveAs("");
}
Manual steps for deleting all lines below the first 1000 lines:
- Open the file, caret is at top of the file.
- Press Ctrl+G to execute command Search - Goto.
- Enter 1001.
- Press RETURN key or click on button Goto.
- Press Ctrl+Shift+End to move caret to end of file and additionally select everything from start of line 1001.
- Press key DEL to delete the selected block.
- Save the modified file with Ctrl+S