Monday, January 27, 2014

Vim: Word Wrap and Disable Automatic New Line


Vim has many features and you can configure in the way you want to make the most of it. To wrap lines you need to change your vimrc file and also to disable the automatic new line behavior.

When you are typing text Vim will automatically insert a new line after the 80 column. This is not convenient and it's very annoying if you use Vim to write besides programming as I do.
Another nice feature is to have a left margin so text is not right next to the window border.

Here's my vimrc file:


" Word wrapping and disable new line automatically
set wrap
set linebreak
set nolist  " list disables linebreak
set textwidth=0
set wrapmargin=0
set formatoptions-=tc

" Margin between text and window's border
set foldcolumn=3


And here's how the text looks like with the new configuration:




I really like Vim and I use it on Mac, Unix and Windows because it's a very light weight editor and you can make Vim a full writing tool like WriteRoom, or al full programming editor to code and compile.
You can also try my Vim green on black background colour scheme if you like.

Monday, December 9, 2013

Vim Green Black Color Scheme

Vim has become my most used writing and light programming tool. I've tried different color schemes and finally created my own. It's green and dark green on a black background.
I've set the cursor color magenta to quickly find where you are at when editing. A color scheme it's a very particular thing and you may even want to create your own!
As you can see this Vim green black color scheme  it's very relaxing for the eyes. I've called this Vim theme defaultme.vim and here is the color file:

" Vim color file
" Maintainer:    Maria
" Last Change:    2013 Dec

" This is a Vim dark color scheme with black background and green foreground colors

hi clear

if version > 580
    " no guarantees for version 5.8 and below, but this makes it stop
    " complaining
    hi clear
    if exists("syntax_on")
        syntax reset
    endif
endif

" Load the syntax highlighting defaults, if it's enabled.
if exists("syntax_on")
  syntax reset
endif

let colors_name = "defaultme"

" highlight groups

" Set nice colors  green foreground on dark background
highlight Normal guifg=#00FF00
highlight Normal guibg=#000000

hi Cursor       guifg=black          guibg=magenta        gui=none
hi ErrorMsg     guifg=white          guibg=red            gui=none
hi VertSplit    guifg=gray40         guibg=gray40        gui=none
hi Folded       guifg=DarkSlateGray3 guibg=gray40        gui=none
hi FoldColumn   guifg=tan            guibg=#000000        gui=none
hi IncSearch    guifg=#b0ffff        guibg=#2050d0
hi LineNr       guifg=burlywood3     gui=none
hi ModeMsg      guifg=SkyBlue        gui=none
hi MoreMsg      guifg=SeaGreen       gui=none
hi NonText      guifg=cyan           gui=none
hi Question     guifg=springgreen    gui=none
hi Search       guifg=gray80         guibg=#445599        gui=none
hi SpecialKey   guifg=cyan           gui=none
hi StatusLine   guifg=black          guibg=green        gui=bold
hi StatusLineNC guifg=grey           guibg=gray40        gui=none
hi Title        guifg=#ff4400        gui=none            gui=bold
hi Visual       guifg=gray17         guibg=tan1            gui=none
hi WarningMsg   guifg=salmon         gui=none
hi Pmenu        guifg=white          guibg=#445599        gui=none
hi PmenuSel     guifg=#445599        guibg=gray
hi WildMenu     guifg=gray           guibg=gray17        gui=none
hi MatchParen    guifg=cyan           guibg=#6C6C6C        gui=bold
hi DiffAdd      guifg=black          guibg=wheat1
hi DiffChange   guifg=black          guibg=skyblue1
hi DiffText     guifg=black          guibg=hotpink1        gui=none
hi DiffDelete   guibg=gray45         guifg=black        gui=none

" syntax highlighting groups
hi Comment      guifg=darkcyan         gui=none
" olive
hi Constant     guifg=#808000       gui=none
hi Identifier   guifg=#808000        gui=none
hi Function     guifg=#82EF2A        gui=none
hi Statement    guifg=darkcyan        gui=none
hi PreProc      guifg=#82EF2A        gui=none
hi Type         guifg=darkgreen        gui=none
hi Special      guifg=darkmagenta    gui=none
hi Ignore       guifg=red            gui=none
hi Todo         guifg=red            guibg=yellow2     gui=none

" color terminal definitions
hi SpecialKey   ctermfg=red
hi NonText      cterm=bold           ctermfg=darkblue
hi Directory    ctermfg=darkcyan
hi ErrorMsg     cterm=bold           ctermfg=7         ctermbg=1
hi IncSearch    cterm=NONE           ctermfg=yellow    ctermbg=green
hi Search       cterm=NONE           ctermfg=white     ctermbg=grey
hi MoreMsg      ctermfg=darkgreen
hi ModeMsg      cterm=NONE           ctermfg=brown
hi LineNr       ctermfg=3
hi Question     ctermfg=green
hi StatusLine   cterm=bold,reverse
hi StatusLineNC cterm=reverse
hi VertSplit    cterm=reverse
hi Title        ctermfg=5
hi Visual       cterm=reverse
hi VisualNOS    cterm=bold,underline
hi WarningMsg   ctermfg=1
hi WildMenu     ctermfg=0            ctermbg=3
hi Folded       ctermfg=darkgrey     ctermbg=NONE
hi FoldColumn   ctermfg=darkgrey     ctermbg=NONE
hi DiffAdd      ctermbg=4
hi DiffChange   ctermbg=5
hi DiffDelete   cterm=bold           ctermfg=4         ctermbg=6
hi DiffText     cterm=bold           ctermbg=1
hi Comment      ctermfg=darkcyan
hi Constant     ctermfg=brown
hi Special      ctermfg=5
hi Identifier   ctermfg=6
hi Statement    ctermfg=3
hi PreProc      ctermfg=5
hi Type         ctermfg=2
hi Underlined   cterm=underline      ctermfg=5
hi Ignore       ctermfg=darkgrey
hi Error        cterm=bold           ctermfg=7         ctermbg=1


Al you've got to do is copy it in a file and name it as defaultme.vm then place it on the color folder. If you use Vim for writing you can tuning it to make it like the WriteRoom writing enviroment.