coteditor/cot

Please add a cot option to place cursor after last character in file

drq883 opened this issue · 2 comments

Environment

  • CotEditor: 3.6.9 (305)
  • System: macOS Version 10.14.1 (Build 18B75)
  • Language: English

Short Description

I have an automated process that pops up a cotedit window every hour and prompts me for input.
It would be nice for an option to be added, maybe --endoffile that would place the cursor on the very last character. I used to use wc -l on the file, add 1 to that value and add options --line <count> --column 99, but that stopped working. Most of the time now, it puts the cursor on the very first byte.

Steps to Reproduce the Issue

It's not an issue, just a request

Expected Result

Running cot --endoffile <filename> would edit the file and position cursor after last byte.

Oh sorry, this must be a side effect that I changed the internal character counting algorithm for scripting and cot command. I forgot to write the change in the release notes.

By the way, current --line option accepts also a negative number, and it means counting lines from the end. In addition, I changed the character location counting from 0-based to 1-based in the next version (cf. #826). Therefore, I need anyway change also the current behavior of cot command for --column option.
So, in the next version, I will make cot --line -1 --column -1 <filename> put the cursor at the end of the document. This may better than introducing a new option, such as --endoffile ;-)

(And it seems I also need to write documentation about this negative character/line number rule.)

Thanks.

I've modified my code to use --line -1 and it works perfectly.

I look forward to --column -1 working and until then I'm figuring the column with:

$column = int(`tail -1 $file | tr -d '\n'|wc -c`);