vim | insert filename into file
Hi, how can anyone add the filename in the file in ex-mode? C-R% and %p works only in normal mode Thanks, Nikos
Re: vim | insert filename into file
Hi, Nikolaos A. Patsopoulos wrote: how can anyone add the filename in the file in ex-mode? C-R% and %p works only in normal mode :put % Regards, Jürgen -- Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us. (Calvin)
Re: vim | insert filename into file
Jürgen Krämer wrote: Hi, Nikolaos A. Patsopoulos wrote: how can anyone add the filename in the file in ex-mode? C-R% and %p works only in normal mode :put % Regards, Jürgen That seems to insert the filename in random place. What if I want to place it e.g. in the beginning of each line?
Re: vim | insert filename into file
If you don't want to put the filename on a new line as :put % does, maybe try :normal %p -dan
Re: vim | insert filename into file
how can anyone add the filename in the file in ex-mode? C-R% and %p works only in normal mode :put % Or, if you need to insert it at a particular place, :10s/$/\=' '.expand('%') will put it at the end of line #10. The basic idiom involves replacing something (EOL, BOL, or some offset in the line) with an evaluated expression that uses expand('%') You can read more at :help sub-replace-special :help expand() -tim
Re: vim | insert filename into file
To place at the beginning of each line try :%normal %P -dan
Re: vim | insert filename into file
:put % That seems to insert the filename in random place. What if I want to place it e.g. in the beginning of each line? It inserts it on the line below where the cursor currently is. You can specify a target (as in :30put % which will put it below line #30) If you want it at the beginning of each line, you can use my aforementioned suggestion of :%s/^/\=expand('%').': ' (which also adds a colon and a space for visualization purposes, but is totally omittable if you want) -tim
Re: vim | insert filename into file
Tim Chase wrote: :put % That seems to insert the filename in random place. What if I want to place it e.g. in the beginning of each line? It inserts it on the line below where the cursor currently is. You can specify a target (as in :30put % which will put it below line #30) If you want it at the beginning of each line, you can use my aforementioned suggestion of :%s/^/\=expand('%').': ' (which also adds a colon and a space for visualization purposes, but is totally omittable if you want) -tim :%s/^/\=expand('%') works great! Thank you all