Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

template <class T> void pv(T a, T b) {
	for(typeof(a) it = a; it != b; ++it)
		cerr << *it << " ";
	cerr << endl;
}

#define all(v) (v).begin(), (v).end()

vector<string> text;
vector<char> command;

int cursol_row;
int cursol_col;

void com_a() {
	cursol_col = 0;
}

void com_e() {
	cursol_col = text.at(cursol_row).length() - 1;
}

void com_p() {
	if(cursol_row > 0) cursol_row--;
	com_a();
}

void com_n() {
	if(cursol_row < (int)text.size() - 1) cursol_row++;
	com_a();
}

void com_f() {
	if(text[cursol_row][cursol_col] != '^') cursol_col++;
	else if(text[cursol_row][cursol_col] == '^' && cursol_row < (int)text.size() - 1) {
		com_f()
	}
}

void com_b() {
	if(cursol_col > 0) cursol_col--;
	else if(cursol_col == 0 && cursol_row > 0) {
		cursol_row--;
		com_e();
	}
}

void show_cursol() {
	cerr << "ROW: " << cursol_row << " COL: " << cursol_col << endl;
}

void com_d() {
	if(text[cursol_row][cursol_col] != '^') {
		string line = text[cursol_row];
		string left = line.substr(0, cursol_col);
		string right = line.substr(cursol_col + 1);
		text[cursol_row] = left + right;
	} else if(text[cursol_row][cursol_col] == '^' && cursol_row < (int)text.size() - 1) {
		string line = text[cursol_row];
		line = line.substr(0, line.length() - 1) + text[cursol_row + 1];
		text[cursol_row] = line;

		vector<string>::iterator it = text.begin();
		advance(it, cursol_row + 1);
		text.erase(it);
	}
}

string buffer;

void com_k() {
	if(text[cursol_row][cursol_col] == '^' && cursol_row < (int)text.size() - 1) {
		com_d(); buffer = "^";
	}
	else if(text[cursol_row][cursol_col] != '^') {
		string line = text[cursol_row];
		buffer = line.substr(cursol_col);
		buffer = buffer.substr(0, buffer.length() - 1);
		text[cursol_row] = line.substr(0, cursol_col) + "^";
	}
}

void com_y() {
	if(buffer == "^") {
		string line = text[cursol_row];
		string fs = line.substr(0, cursol_col) + "^";
		string sc = line.substr(cursol_col);
		text[cursol_row] = fs;

		vector<string>::iterator it = text.begin();
		advance(it, cursol_row + 1);
		text.insert(it, sc);
		cursol_row++;
		cursol_col = 0;
	}
	else if(buffer != "") {
		string line = text[cursol_row];
		string left = line.substr(0, cursol_col);
		string right = line.substr(cursol_col);
		text[cursol_row] = left + buffer + right;
	}
}

int main() {
	buffer = "";

	cursol_row = 0;
	cursol_col = 0;

#if 1
	for(string line; getline(cin, line) && line != "END_OF_TEXT";) {
		text.push_back(line + "^");
	}
	for(char c; cin >> c && c != '-'; ) {
		command.push_back(c);
	}
#else
	for(string line; getline(cin, line) && line != "-";) {
		text.push_back(line + "^");
	}
	for(char c; cin >> c && c != '-'; ) {
		switch(c) {
			case 'a': com_a(); break;
			case 'e': com_e(); break;
			case 'p': com_p(); break;
			case 'n': com_n(); break;
			case 'f': com_f(); break;
			case 'b': com_b(); break;
			case 'd': com_d(); break;
			case 'k': com_k(); break;
			case 'y': com_y(); break;
			default: break;
		}
		pv(all(text));
		show_cursol();
	}
#endif

	
#if 0
	pv(all(text));
	pv(all(command));
#endif


#if 1
	for(int i = 0; i < (int)command.size(); i++) {
		char c = command[i];
		switch(c) {
			case 'a': com_a(); break;
			case 'e': com_e(); break;
			case 'p': com_p(); break;
			case 'n': com_n(); break;
			case 'f': com_f(); break;
			case 'b': com_b(); break;
			case 'd': com_d(); break;
			case 'k': com_k(); break;
			case 'y': com_y(); break;
			default: break;
		}
	}

	for(int i = 0; i < (int)text.size(); i++) {
		cout << text[i].substr(0, text[i].length() - 1) << endl;
		// cout << text[i] << endl;
	}
#endif

	return 0;
}

Compiler output:
a.cc: In function 'void com_f()':
a.cc:43:24: error: expected ';' before '}' token
   43 |                 com_f()
      |                        ^
      |                        ;
   44 |         }
      |         ~