[Startup Engineering] #TIP: How to edit sources using vi
[sourcecode language=”bash”]
ubuntu@ip-172-31-5-125:~$ cd bitstarter
ubuntu@ip-172-31-5-125:~/bitstarter$ cat web.js
var express = require(‘express’);
var app = express.createServer(express.logger());
app.get(‘/’, function(request response)){
reponse.send(‘Hello World!’);
});
var port = process.env.PORT || 5000;
app.listen(port, function(){
console.log("Listening on " + port);
});
ubuntu@ip-172-31-5-125:~/bitstarter$ vi web.js
[/sourcecode]
Then, you can see vi-editor. press ‘i’ in your keyboard. and vi become edit mode.
[sourcecode language=”javascript”]
var express = require(‘express’);
var app = express.createServer(express.logger());
app.get(‘/’, function(request response)){
reponse.send(‘Hello World!’);
});
var port = process.env.PORT || 5000;
app.listen(port, function(){
console.log("Listening on " + port);
});
~
~
~
~
~
— INSERT — // <- edit mode
[/sourcecode]
Move the cursor using the direction key. If press ESC after editing, get out of edit mode.
If you want to end vi, press the semicolon(:) and wq(=write and quit).