LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-08-2011, 05:02 AM   #1
siva balan
LQ Newbie
 
Registered: Jul 2010
Posts: 25

Rep: Reputation: 0
vim editor


in MS word,
we can set The default text(as template) whenever we open it.
so we can avoid the repetitive typing.

is it possible in vim editor?

i need to type,
Code:
<html>
<body>
<script>

script goes here.......


</script>
</body>
</html>
whenever i write the new script..
i am repeating the above format..
is there any possiblity to set vim editor to display the above text as default?
Edit/Delete Message
 
Old 02-08-2011, 05:09 AM   #2
prodev05
Member
 
Registered: Jul 2009
Location: Planet Earth
Distribution: Unix & Linux Variants
Posts: 304

Rep: Reputation: 20
Yes it is possible .

Follow me
 
Old 02-08-2011, 05:51 AM   #3
sumeet inani
Member
 
Registered: Oct 2008
Posts: 908
Blog Entries: 26

Rep: Reputation: 49
I think siva balan asked that suppose I ran
$vim 1.html #where 1.html does not exists
Then I should not get empty file to edit , instead file filled with code he has mentioned.

prodev05 , as you pointed I created file ~/.vim/template/template.html containing code mentioned above
Now I ran
$vim 1.html
Still 1.html is empty
 
Old 02-08-2011, 05:53 AM   #4
prodev05
Member
 
Registered: Jul 2009
Location: Planet Earth
Distribution: Unix & Linux Variants
Posts: 304

Rep: Reputation: 20
create your type of template in the template.* file.
 
Old 02-09-2011, 02:37 AM   #5
sumeet inani
Member
 
Registered: Oct 2008
Posts: 908
Blog Entries: 26

Rep: Reputation: 49
I have extracted the contents of vim-template-0.2.1.zip to ~/.vim/template.
Code:
$tree ~/.vim/template
/home/lxuser/.vim/template
|-- doc
|   |-- template.jax
|   `-- template.txt
|-- plugin
|   `-- template.vim
`-- template.html
$cat ~/.vim/template/template.html 
<html>
</html>
I am using ubuntu 10.04.

Can you tell what I did wrong & what I should have done ?

Last edited by sumeet inani; 02-09-2011 at 02:58 AM.
 
Old 02-10-2011, 03:49 AM   #6
sumeet inani
Member
 
Registered: Oct 2008
Posts: 908
Blog Entries: 26

Rep: Reputation: 49
I found this -> http://code.google.com/p/lh-vim/wiki/muTemplate

I downloaded 4 vimballs namely - lh-map-tools-1.1.2.vba , lh-vim-lib-2.2.4 , searchInRuntime-2.1.8.vba & mu-template-2.2.1.vba
Then opened them in vim & ran
Code:
:source %
Now if you create new file ending in c then it will be filled with

Code:
//========================================================================
  2 /**@file        /home/lxuser/.vim/vimball/try.c
  3  * @author      lxuser
  4  * @version     «version»
  5  * @date
  6  *      Created:        Thursday 10 February 2011 03:13:36 PM IST \n
  7  *      Last Update:    Thursday 10 February 2011 03:13:36 PM IST
  8  */
  9 /*------------------------------------------------------------------------
 10  * Description: «description»
 11  * 
 12  *------------------------------------------------------------------------
 13  * History:     «history»
 14  * TODO:        «missing features»
 15  *========================================================================
 16  */
 17 
 18 
 19 /*===========================================================================*/
 20 /*===============================[ Includes ]================================*/
 21 /*===========================================================================*/
 22 #include "0"
 23 «Includes»
 24 
 25 
 26 /*===========================================================================*/
 27 /*==================================[ «» ]===================================*/
 28 /*===========================================================================*/
 29 «other stuff»
Isn't this great !
You can customise the default files : ~/.vim/after/template/<extension>.template

If you want to uninstall it
then run inside vim
Code:
::RmVimball Same_File_name_with_path
Happy to help

Last edited by sumeet inani; 02-10-2011 at 03:50 AM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
vim editor bimleshkumar007 Linux - Newbie 3 01-04-2011 06:03 PM
LXer: Personalize and Optimize Vim editor using Packt’s new Vim 7.2 book LXer Syndicated Linux News 0 05-20-2010 10:20 PM
Editor comparison: vim VS vim-lite, Cleaning vim Ruler2112 *BSD 4 04-13-2009 04:26 PM
vim editor kosys Linux - General 6 12-31-2007 10:48 AM
vim editor shabbirhai Linux - General 5 03-02-2006 02:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration