ed invalid address macOS

Adam
/Delete/,/endif/p
?
invalid address
/Delere/,/endif/p
?
no match

Does it mean it understands latin only?

/Dele/,/endif/p
?
invalid address
/Del/,/endif/p
?
invalid address

No, what am I doing wrong? I'm typing out all letters without any mistakes.

I have macOS.

The following is a sample from the file I'm editing that exhibit the same behaviour when editing it using the above ed command:

"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" => Editing mappings
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Remap VIM 0 to first non-blank character
map 0 ^

" Move a line of text using ALT+[jk] or Command+[jk] on mac
nmap <M-j> mz:m+<cr>`z
nmap <M-k> mz:m-2<cr>`z
vmap <M-j> :m'>+<cr>`<my`>mzgv`yo`z
vmap <M-k> :m'<-2<cr>`>my`<mzgv`yo`z

if has("mac") || has("macunix")
  nmap <D-j> <M-j>
  nmap <D-k> <M-k>
  vmap <D-j> <M-j>
  vmap <D-k> <M-k>
endif

" Delete trailing white space on save, useful for some filetypes ;)

if has("autocmd")
    autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.coffee :call CleanExtraSpaces()
endif
Kusalananda

The first endif occurs before the first Delete, so ed gets confused about the range being specified "backwards".

You will want to first find the first occurence of Delete, then apply the command from that line down to the next endif:

1,/Delete/
.,/endif/p

The first command will place the cursor on the first line of the file that contains the word Delete, and the second command will print the lines from that line down to the next line that contains the word endif.


If you were to give the same command in vi, it would complain with "The second address is smaller than the first", and vim would ask "Backwards range given, OK to swap (y/n)?" when giving the editing command :/Delete/,/endif/p.

sed would not have an issue as it looks for the first address before it starts looking for the second address (since it's a stream editor).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TOP Ranking

HotTag

Archive