Web Authoring with Vim
June 18th, 2007 toydi Posted in Network, Text Manipulation, vim | Hits: 62282 | 10 Comments »
In usual editing, to open a file with vim, we run the command:
vim /path/to/file
It is also possible to browse a directory using vim:
vim /path/to/directory/
When we are inside vim, to save a file, we use the :write
command, :read
to read an existing file into current buffer; or using :tabnew /path/to/file
to open a file in a new tabbed window.
Remote editing
When it comes to remote editing, (quite surprising me) vim simply reuses the same command set to access files or directories from a remote machine.
For example, to open a file in my web hosting server:
vim ftp://ftp.teohuiming.name/public_html/blog/index.html
To browse my web directory in the server (the trailing slash in the URL is essential to indicate it is a directory):
vim ftp://ftp.teohuiming.name/public_html/
Let say, I have opened the file index.html
and made some changes. When I run the :write
command, vim immediately sends an FTP request to my server to update the file.
FTP is not the only allowed protocol, vim is also capable to access remote machines through HTTP, WebDAV, SSH (scp, sftp) etc. For more details, run help command :help netrw
in vim.
Config vim to use Passive FTP
If you have connected successfully to your FTP server, able to send FTP requests, but always fail on receiving data from the server, you may need to turn on the passive mode in FTP to fix the problem.
To configure vim to use passive FTP, we need to force vim to use pftp
by appending the line below in vim config file ~/.vimrc
:
let g:netrw_ftp_cmd = 'pftp'
Extra tips
Use :0r
to load template. I keep a few HTML document templates, and used do this whenever I want to create a new document:
cp html401.tpl tutorial2.html
vim tutorial2.html
But if you are already inside vim, it’s easier to open a blank page with :tabnew
, and load the template directly using :0r html401.tpl
.
Insert ISO6801 date format. In the Web world, we often need to insert ISO6801 formatted timestamp when writing standard documents such as Atom. To insert a timestamp like 2007-06-18T23:14:02+0800
in vim, try :r !date -Iseconds
.
June 5th, 2011 at 3:23 am
I actually wanted to post a brief message in order to appreciate you for all the remarkable ideas you are showing on this site. My extended internet lookup has at the end of the day been recognized with sensible knowledge to write about with my friends and classmates. I would assert that most of us visitors actually are unquestionably endowed to be in a magnificent network with very many brilliant individuals with great basics. I feel pretty fortunate to have come across the webpage and look forward to really more fun minutes reading here. Thank you once more for all the details.
September 9th, 2011 at 11:30 pm
I think this is among the most significant information for me. And i am glad I am reading your article. But should remark on some general things, The website style is great, the articles is really nice. Good job, cheers.
July 19th, 2013 at 2:48 pm
I found the same file but not including the trojan at keygenpen.
February 4th, 2015 at 3:48 am
Hello to every body, it’s my first pay a visit of this web
site; this web site consists of awesome and actually good material for
visitors.
May 6th, 2015 at 12:53 am
I slept in I can’t believe thius is pllanetary annihilation cracck ResidentSleeper fire emblem,
the speedrun. Playing the game is boring to watch a planetary annihilation crack 3 hour
speedrun of. Stayts to complain Kappa I actgually prefer rpg speed runs.
Kappa Yees f f F girl’s name in pokemon? 3 hours
of this?
May 28th, 2015 at 10:31 am
I blog frequently and I seriously appreciate your content.
This great article has truly peaked my interest.
I’m going to book mark your blog and keep checking for new details about once a week.
I subscribed to your RSS feed too.
August 25th, 2015 at 4:23 am
Soundtrack PES 2011 was released for Microsoft Windows and wass
well received by the Mannschaft, Weedens is trying to strike with Klose.
Com FIFA wins aat online modes,as last PES games were’nt good in this game
are just wonderful! Sometimes, you have to push L2 twice tto activate the offensive tactics.
Chems we told you, wioth realistic pro evolution soccer 2014 keygen, crack, cheat animations.
December 3rd, 2015 at 3:26 pm
hello!,I like your writing so so much! proportion we keep in touch extra approximately your article on AOL?
I need a specialist on this space to unravel my problem.
May be that is you! Looking forward to peer you.
January 6th, 2016 at 8:56 am
Journals.
November 24th, 2020 at 4:06 pm
viagra in australia over the counter shoppers drugmart viagra substitute for viagra