Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim: insert text from a file at current cursor position

Tags:

vim

To insert text from a file in the current Vim buffer I use :r filename to insert the text below the cursor or :0r filename to insert in the first line.

How do you insert the contents of a file where [Cursor] is located?

Actual line with some coding [Cursor]  // TODO for later version   Line below actual line ... 
like image 594
vbd Avatar asked Feb 09 '11 10:02

vbd


People also ask

How do you insert a character in vi after current cursor position?

Type a (append) to insert text to the right of the cursor. Experiment by moving the cursor anywhere on a line and typing a , followed by the text you want to add. Press Esc when you're finished. Type A to add text to the end of a line.

Which command will be used with vi editor to insert text to left of cursor?

Insert text to the left of the cursor by typing i from command mode. Type I to insert text at the beginning of a line. The command moves the cursor from any position on that line. Press Esc to return to command mode after you type the desired text.


2 Answers

This inserts the contents of the file whose path is at the cursor position:

:r <cfile> 
like image 161
user2830191 Avatar answered Sep 28 '22 07:09

user2830191


Insert a line break, read the file, and then take out the line break...

like image 35
awm Avatar answered Sep 28 '22 07:09

awm