I am working on an application that supports the ability to launch an external editor on XML validation errors, where the validation error will include the specific line and character offset in the line the error occurs. For example, "74:62" represents the 74th line and 62nd character of that line, which is also said as, "line 74, column 62".
The problem I am having is that editors treat "column" differently. For Vim, column 62 is a character position. While in Oxygen XML Editor, Notepad++, and Emacs, column is a rendered position.
Why does this distinction matter? If the target line has tab characters, Notepad++ and Emacs "column" no longer represents character offset, and for those editors the cursor gets located differently: Notepad++ treats tab as 4 columns and Emacs as 8 (by default).
Here are the commands I use for each editor, where 'L' is the line number, 'C' is the column number, and 'FILE' is the file to open:
gvim "+call cursor(L,C)" FILE
oxygen FILE#line=L;column=C
notepad++ -nL -cC -lxml FILE
emacs +L:C FILE
(See @Rorschach's answer below for method that does work)For Notepad++ and Emacs, are there command-line invocations that will place the cursor at a character position relative to the line?
Edit
Oxygen XML Editor behaves as expected, where column
parameter is interepreted as a character offset from line
. See @Rorschach's answer below regarding Emacs, I do not have a solution for Notepad++.
As a workaround for different character display widths in emacs you could add a hook to run after the file loads.
# assuming there are some variables (eg. shell)
# holding the line/column as in the normal command
L=4
C=2
emacs --eval "(add-hook 'emacs-startup-hook (lambda () (goto-line $L) (forward-char $C)))" input_file.xml