Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

« Newer Snippets
Older Snippets »
Showing 11-15 of 15 total

Linux - File vimrc

// Configurazione minima di VIM

syntax on

set backspace=indent,eol,start
set nocompatible " rende vim compatibile a vi

set hlsearch
set incsearch
set autoindent
set textwidth=0
set ruler " fa apparire la posizione del cursore
set history=50

if has("autocmd") " permette il riconoscimento del linguaggio
	filetype plugin indent on
endif

set showcmd
set showmatch

set nowrap

colorscheme delek

vimrc for 2 space tab replacements

~/.vimrc:
set softtabstop=2
set shiftwidth=2
set tabstop=2
set expandtab

Using VIM as a syntax highlighting engine from Ruby

You can use VIM as a syntax highlighting engine for code fragments in your blogs etc. The below code snippet works sort of, but it is slow for me. Not sure at the moment whether it is VIM or something else. Perhapps others can try it out and suggest speed or other improvments.

       def  vimsyn(text, filetype)
           synfile = Tempfile.new('synfile')
           synfile.close
           codefile = Tempfile.new('codefile')
           codefile << text
           codefile.close

           # filetype="matlab"

           expr = %Q%/usr/local/bin/vim -f -n -X -e -s -c \
               "set filetype=#{filetpe}" \
               -c "syntax on" \
               -c "set background=dark" \
               -c "let html_use_css=1" \
               -c "run syntax/2html.vim" \
               -c "wq! #{synfile.path}" -c "q" \ 
               #{codefile.path}%

           `#{expr}`
           html = IO.readlines(synfile.path).join
           body = html.match(/<body.*<\/body>/m)[0]
           css  = html.match(/<style.*<\/style>/m)[0]
           css.gsub!(/pre/,'pre.code')
           css.gsub!(/^body.*$/,'')
           body.gsub!(/^<body/,'<div')
           body.gsub!(/<\/body>/,'<div>')                                        
           body.gsub!(/<pre>/,'<pre class=code>')

           return css+body
       end

.vimrc settings to uncomment blocks of text

Add to .vimrc so you can un comment blocks of text quickly and easily.

" ,cc clear the comments
map ,cc :s/^\/\/\\|^--\\|^> \\|^[#"%!;]//<CR><Esc>:nohlsearch<CR>

.vimrc settings to autocomment blocks of text.

Add to .vimrc so you can comment blocks of text in perl/java/etc.

Highlight a block of text and hit ,# and it is commented out in perl.

" , #perl # comments
map ,# :s/^/#/<CR>

" ,/ C/C++/C#/Java // comments
map ,/ :s/^/\/\//<CR>

" ,< HTML comment
map ,< :s/^\(.*\)$/<!-- \1 -->/<CR><Esc>:nohlsearch<CR>

" c++ java style comments
map ,* :s/^\(.*\)$/\/\* \1 \*\//<CR><Esc>:nohlsearch<CR>
« Newer Snippets
Older Snippets »
Showing 11-15 of 15 total