Enhancing Vim

Just want to have a nice chat with your beer? Go ahead ;-)

Enhancing Vim

Postby aguilarojo » 14 May 2009, 04:47

One of the most versatile and advanced editors available is vim. It is advanced enough to qualify as a Turing machine. For those who are unsure what that is there's a page discussing the concept in some detail complete with a JavaScript presentation exemplifying the principle very nicely within your browser. Click on the phrase "Basic Turing Machine" which appears on that page in blue and without the quotes. Here is that link:

http://stackoverflow.com/questions/236000/whats-a-turing-machine/236027

I'm sharing this configuration file which can be expanded or further developed according to one's needs. Obviously this is intended to be a dot (.) file within the base of the root tree, enabling anyone with root access to invoke the functions defined in this file whenever they are working on a file or creating a file within vim. The functions do several things:


  • Function Keys can be defined.
  • Within vim, Function Keys are invoked by clicking the defined keys once.
  • To have the function cease, click upon the same defined key once more.
  • The first function visually identifies indentations in a clear and identifiable manner.
  • The second function color codes number lines and functions according to the commands one invokes using vim's
    internal color code and font style system.
  • The third function clarifies for vim users when the Paste function is active.

The functions in .vimrc can be expanded upon as needed to include other functions and commands others find useful.

Code: Select all

" Name:       .vimrc
" Programmer:    Derick Centeno
" Date:      3.23.05

" Purpose:    Configuration file for vim.
" Modified by DC: 3.23.05 and 7.9.05

" This file will exist in the YDL root account (of the entire system) as a . file or dot file called .vimrc.
" This file is modeled on vimrc_example.vim located within /usr/share/vim/vim70.
" Normally vim-extensions are used to make modifications.  Using vimrc however is acceptable.

" If you want true vi-compatibility change the following statements.
set nocompatible   " Use Vim defaults instead of 100% vi compatibility.
set backspace=2   " more powerful backspacing

" Don't write backup file if vim is being called by "crontab -e".
au BufWrite /private/tmp/crontab.* set nowritebackup

" Don't write backup file if vim is being called by "chpass"
au BufWrite /private/etc/pw.* set nowritebackup

set listchars=tab:\|\
set wildchar=<Tab>
set background=light
set tabstop=4
set ruler
set showmode
syntax on

" Programmer: DC 7.9.05.  Inserted the next line based upon older .bash_profile work involving EXINIT.
hi statement cterm=bold ctermfg=Red|hi LineNr ctermfg=DarkCyan
set autoindent
set nomesg
set showmatch
set mps+=<:>
set matchtime=1
au FileType fortran set textwidth=72
au FileType c set cindent

" First Function Key.
" ShowIndent Mode On/Off.
map <F2> :call ShowIndent_on_off()<CR>
let indent_mode = 0
func! ShowIndent_on_off()
   if g:indent_mode ==0
      set list
      let g:indent_mode = 1
    else
      set nolist
      let g:indent_mode = 0
   endif
   return
endfunc

" Second Function Key.
" ShowNumbers Mode On/Off.
map <F3> :call ShowNumbers_on_off()<CR>
let number_mode = 0
func! ShowNumbers_on_off()
   if g:number_mode == 0
   "Programmer Derick Centeno 7/9/2005.  Modified next line based on older work using EXINIT.
      set nu popt=paper:letter,number:y
      let g:number_mode = 1
   else
      set nonumber
      let g:number_mode = 0
   endif
   return
endfunc

" Third Function Key.
" Allows notification within vim that the Paste function is active.
set pastetoggle=<F4>


Caveats before using this file:


  • Make sure that either you are the System Administrator (SA) or have gained permission from the SA of the system
    before you use this file.
  • Make sure that this file is not erasing or destroying an essential file of the same name.

Hopefully this submission will help others become comfortable exploring and working with vim.
Last edited by aguilarojo on 11 May 2012, 00:00, edited 1 time in total.

Everything on the Earth has a purpose.
Every disease an herb to cure it.
And every person has a mission.
This is the Indian Theory of Existence.
-- Morning Dove, Salish (1888-1936)
User avatar
aguilarojo
ydl guru
ydl guru
 
Posts: 227
Joined: 06 May 2009, 14:50
Location: New York City

Re: Enhancing Vim

Postby aguilarojo » 17 Sep 2010, 18:48

aguilarojo wrote:One of the most versatile and advanced editors available is vim. It is advanced enough to qualify as a Turing machine. For those who are unsure what that is there's a page discussing the concept in some detail complete with a JavaScript presentation exemplifying the principle very nicely within your browser. Click on the phrase "Basic Turing Machine" which appears on that page in blue and without the quotes. Here is that link:

http://stackoverflow.com/questions/236000/whats-a-turing-machine/236027

As to using vim such that useful features are implemented efficiently, I'm submitting/sharing this configuration file which can be expanded or further developed according to one's needs. Obviously this is intended to be a dot (.) file within the base of the root tree, enabling anyone with root access to invoke the functions defined in this file whenever they are working on a file or creating a file within vim. The functions do several things:


  • Function Keys can be defined.
  • Within vim, Function Keys are invoked by clicking the defined keys once.
  • To have the function cease, click upon the same defined key once more.
  • The first function visually identifies indentations in a clear and identifiable manner.
  • The second function color codes number lines and functions according to the commands one invokes using vim's
    internal color code and font style system.
  • The third function clarifies for vim users when the Paste function is active.

The functions in .vimrc can be expanded upon as needed to include other functions and commands others find useful.

Code: Select all

" Name:       .vimrc
" Programmer:    Derick Centeno
" Date:      3.23.05

" Purpose:    Configuration file for vim.
" Modified by DC: 3.23.05 and 7.9.05

" This file will exist in the YDL root account (of the entire system) as a . file or dot file called .vimrc.
" This file is modeled on vimrc_example.vim located within /usr/share/vim/vim70.
" Normally vim-extensions are used to make modifications.  Using vimrc however is acceptable.

" If you want true vi-compatibility change the following statements.
set nocompatible   " Use Vim defaults instead of 100% vi compatibility.
set backspace=2   " more powerful backspacing

" Don't write backup file if vim is being called by "crontab -e".
au BufWrite /private/tmp/crontab.* set nowritebackup

" Don't write backup file if vim is being called by "chpass"
au BufWrite /private/etc/pw.* set nowritebackup

set listchars=tab:\|\
set wildchar=<Tab>
set background=light
set tabstop=4
set ruler
set showmode
syntax on

" Programmer: DC 7.9.05.  Inserted the next line based upon older .bash_profile work involving EXINIT.
hi statement cterm=bold ctermfg=Red|hi LineNr ctermfg=DarkCyan
set autoindent
set nomesg
set showmatch
set mps+=<:>
set matchtime=1
au FileType fortran set textwidth=72
au FileType c set cindent

" First Function Key.
" ShowIndent Mode On/Off.
map <F2> :call ShowIndent_on_off()<CR>
let indent_mode = 0
func! ShowIndent_on_off()
   if g:indent_mode ==0
      set list
      let g:indent_mode = 1
    else
      set nolist
      let g:indent_mode = 0
   endif
   return
endfunc

" Second Function Key.
" ShowNumbers Mode On/Off.
map <F3> :call ShowNumbers_on_off()<CR>
let number_mode = 0
func! ShowNumbers_on_off()
   if g:number_mode == 0
   "Programmer Derick Centeno 7/9/2005.  Modified next line based on older work using EXINIT.
      set nu popt=paper:letter,number:y
      let g:number_mode = 1
   else
      set nonumber
      let g:number_mode = 0
   endif
   return
endfunc

" Third Function Key.
" Allows notification within vim that the Paste function is active.
set pastetoggle=<F4>


Caveats before using this file:


  • Make sure that either you are the System Administrator (SA) or have gained permission from the SA of the system
    before you use this file.
  • Make sure that this file is not erasing or destroying an essential file of the same name.

Hopefully this submission will help others become comfortable exploring and working with vim.

Everything on the Earth has a purpose.
Every disease an herb to cure it.
And every person has a mission.
This is the Indian Theory of Existence.
-- Morning Dove, Salish (1888-1936)
User avatar
aguilarojo
ydl guru
ydl guru
 
Posts: 227
Joined: 06 May 2009, 14:50
Location: New York City

Re: Enhancing Vim

Postby aguilarojo » 17 Sep 2010, 18:48

aguilarojo wrote:One of the most versatile and advanced editors available is vim. It is advanced enough to qualify as a Turing machine. For those who are unsure what that is there's a page discussing the concept in some detail complete with a JavaScript presentation exemplifying the principle very nicely within your browser. Click on the phrase "Basic Turing Machine" which appears on that page in blue and without the quotes. Here is that link:

http://stackoverflow.com/questions/236000/whats-a-turing-machine/236027

As to using vim such that useful features are implemented efficiently, I'm submitting/sharing this configuration file which can be expanded or further developed according to one's needs. Obviously this is intended to be a dot (.) file within the base of the root tree, enabling anyone with root access to invoke the functions defined in this file whenever they are working on a file or creating a file within vim. The functions do several things:


  • Function Keys can be defined.
  • Within vim, Function Keys are invoked by clicking the defined keys once.
  • To have the function cease, click upon the same defined key once more.
  • The first function visually identifies indentations in a clear and identifiable manner.
  • The second function color codes number lines and functions according to the commands one invokes
    using vim's internal color code and font style system.
  • The third function clarifies for vim users when the Paste function is active.

The functions in .vimrc can be expanded upon as needed to include other functions and commands others find useful.

Code: Select all

" Name:            .vimrc
" Programmer:      Derick Centeno
" Date:            3.23.05

" Purpose:    Configuration file for vim.
" Modified by DC: 3.23.05 and 7.9.05

" This file will exist in the YDL root account (of the entire system) as a . file or dot file called .vimrc.
" This file is modeled on vimrc_example.vim located within /usr/share/vim/vim70.
" Normally vim-extensions are used to make modifications.  Using vimrc however is acceptable.

" If you want true vi-compatibility change the following statements.
set nocompatible   " Use Vim defaults instead of 100% vi compatibility.
set backspace=2   " more powerful backspacing

" Don't write backup file if vim is being called by "crontab -e".
au BufWrite /private/tmp/crontab.* set nowritebackup

" Don't write backup file if vim is being called by "chpass"
au BufWrite /private/etc/pw.* set nowritebackup

set listchars=tab:\|\
set wildchar=<Tab>
set background=light
set tabstop=4
set ruler
set showmode
syntax on

" Programmer: DC 7.9.05.  Inserted the next line based upon older .bash_profile work involving EXINIT.
hi statement cterm=bold ctermfg=Red|hi LineNr ctermfg=DarkCyan
set autoindent
set nomesg
set showmatch
set mps+=<:>
set matchtime=1
au FileType fortran set textwidth=72
au FileType c set cindent

" First Function Key.
" ShowIndent Mode On/Off.
map <F2> :call ShowIndent_on_off()<CR>
let indent_mode = 0
func! ShowIndent_on_off()
   if g:indent_mode ==0
      set list
      let g:indent_mode = 1
    else
      set nolist
      let g:indent_mode = 0
   endif
   return
endfunc

" Second Function Key.
" ShowNumbers Mode On/Off.
map <F3> :call ShowNumbers_on_off()<CR>
let number_mode = 0
func! ShowNumbers_on_off()
   if g:number_mode == 0
   "Programmer Derick Centeno 7/9/2005.  Modified next line based on older work using EXINIT.
      set nu popt=paper:letter,number:y
      let g:number_mode = 1
   else
      set nonumber
      let g:number_mode = 0
   endif
   return
endfunc

" Third Function Key.
" Allows notification within vim that the Paste function is active.
set pastetoggle=<F4>


Caveats before using this file:


  • Make sure that either you are the System Administrator (SA) or have gained permission from the SA
    of the system before you use this file.
  • Make sure that this file is not erasing or destroying an essential file of the same name.

Hopefully this submission will help others become comfortable exploring and working with vim.

Everything on the Earth has a purpose.
Every disease an herb to cure it.
And every person has a mission.
This is the Indian Theory of Existence.
-- Morning Dove, Salish (1888-1936)
User avatar
aguilarojo
ydl guru
ydl guru
 
Posts: 227
Joined: 06 May 2009, 14:50
Location: New York City

Re: Enhancing Vim

Postby Iguana » 21 Sep 2010, 21:08

lol ^.^ quoting yourself 2 times.?.!?.!.
Having fun?
:D
PS3 CECHLO1
GNOME Desktop
Yellowdog Linux 6.2
ihome keyboard
ihome gaming mouse (red)
Iguana
ydl addict
ydl addict
 
Posts: 121
Joined: 01 Apr 2010, 22:49
Location: Florida

Re: Enhancing Vim

Postby aguilarojo » 21 Sep 2010, 22:56

Iguana wrote:lol ^.^ quoting yourself 2 times.?.!?.!.
Having fun?
:D


I must address my own errors. I tried refining and correcting a phrase here and there and the result was what I did not intend. Oh well... I'm really sure that there is no way to correct this now.

Forward and onwards...

Everything on the Earth has a purpose.
Every disease an herb to cure it.
And every person has a mission.
This is the Indian Theory of Existence.
-- Morning Dove, Salish (1888-1936)
User avatar
aguilarojo
ydl guru
ydl guru
 
Posts: 227
Joined: 06 May 2009, 14:50
Location: New York City


Return to Speaker's Corner

Who is online

Users browsing this forum: No registered users and 5 guests

cron