TDLR; I am unable to edit gvim using the _vimrc file
Basically, I want to change some default settings (like background color) in the GUI version of vim (gvim). However, when I make changes to my .vimrc file, my gvim does not react to the changes.
I already have
if has("gui_number")
set number
colorscheme desert
endif
in my .vimrc file, and from what I've read that should make changes in my GVIM, but it doesn't.
I even tried to type some random stuff in the .vimrc file to see if GVIM would display an error, which it did not.
So i think the problem may be my gvim isn't reading my .vimrc file at all. So this may be a pathing problem?
This below is my .vimrc file
source $VIMRUNTIME/vimrc_example.vim
jhgfjhgjhg (This here was to test for an error)
if has('gui_running')
set number
colorscheme desert
endif
set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg1 = substitute(arg1, '!', '\!', 'g')
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg2 = substitute(arg2, '!', '\!', 'g')
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let arg3 = substitute(arg3, '!', '\!', 'g')
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
if empty(&shellxquote)
let l:shxq_sav = ''
set shellxquote&
endif
let cmd = '"' . $VIMRUNTIME . '\diff"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
let cmd = substitute(cmd, '!', '\!', 'g')
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
if exists('l:shxq_sav')
let &shellxquote=l:shxq_sav
endif
endfunction
Here is my .GVIMRC file
version 6.0
if &cp | set nocp | endif
let s:cpo_save=&cpo
set cpo&vim
map! <S-Insert> *
vmap "*d
map Q gq
vmap [% [%m'gv``
vmap ]% ]%m'gv``
vmap a% [%v]%
vmap gx <Plug>NetrwBrowseXVis
nmap gx <Plug>NetrwBrowseX
vnoremap <silent> <Plug>NetrwBrowseXVis :call netrw#BrowseXVis()
nnoremap <silent> <Plug>NetrwBrowseX :call netrw#BrowseX(expand((exists("g:netrw_gx")? g:netrw_gx : '<cfile>')),netrw#CheckIfRemote())
vmap <C-Del> "*d
vmap <S-Del> "*d
vmap <C-Insert> "*y
vmap <S-Insert> "-d"*P
nmap <S-Insert> "*P
inoremap u
let &cpo=s:cpo_save
unlet s:cpo_save
set backspace=indent,eol,start
set backup
set diffexpr=MyDiff()
set display=truncate
set guioptions=egmrLT
set helplang=En
set history=200
set hlsearch
set incsearch
set langnoremap
set nolangremap
set nrformats=bin,hex
set ruler
set runtimepath=~/vimfiles,C:\\Program\ Files\ (x86)\\Vim/vimfiles,C:\\Program\ Files\ (x86)\\Vim\\vim81,C:\\Program\ Files\ (x86)\\Vim\\vim81\\pack\\dist\\opt\\matchit,C:\\Program\ Files\ (x86)\\Vim/vimfiles/after,~/vimfiles/after
set scrolloff=5
set ttimeout
set ttimeoutlen=100
set undofile
set wildmenu
" vim: set ft=vim :
I would hope that my gvim would display lines and a different background, but nothing happens.
edit: should my _vimrc file look exactly like my gvimrc?
I figured it out guys.
So apparently I was supposed to create a _vimrc file in my home directory.
If you are on windows 7 and having the problem where you cant edit your _vimrc file in your VIM directory to change gvimrc, then its because you are trying to edit the wrong _vimrc!! You need to make a different user one in your home directory!
Windows 7:
Open vim, type in :e $HOME/_vimrc
And then put the new settings and save (then reopen GVIM)
Related
I have installed Vim and Vundal, but for some reason the plugins that I put in my _vimrc does not appear when type :PluginInstall. Picture:
As you can see on the left, only Plugin 'VundleView/Vundle.vim' appears even though I have added two other plugins into my _vimrc file. (I am using Windows 10 if that matters.)
What could possibly be the problem here? Am I using the wrong _vimrc file or did I miss some steps?
Here is my vimrc file:
" Vim with all enhancements
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
syntax off
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'preservim/nerdtree'
Plugin 'tpope/vim-fugitive'
" Keep Plugin commands between vundle#begin/end.
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
" Use the internal diff if available.
" Otherwise use the special 'diffexpr' for Windows.
if &diffopt !~# 'internal'
set diffexpr=MyDiff()
endif
function! MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg1 = substitute(arg1, '!', '\!', 'g')
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg2 = substitute(arg2, '!', '\!', 'g')
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let arg3 = substitute(arg3, '!', '\!', 'g')
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
if empty(&shellxquote)
let l:shxq_sav = ''
set shellxquote&
endif
let cmd = '"' . $VIMRUNTIME . '\diff"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
let cmd = substitute(cmd, '!', '\!', 'g')
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
if exists('l:shxq_sav')
let &shellxquote=l:shxq_sav
endif
endfunction
I've searched high and low but cannot get the correct syntax etc. I'd like to set my vim_rc file so I'm using the evening theme and 16pt Lucida console text as a default. I've tried many combinations and I am not having much joy on the web. At present, I'm receiving the following error:
Error detected while processing C:\Program Files
(x86)\Vim\_vimrc:
line 47:
E518: Unknown option: Console\ 14
and my vim file (based on web advice) looks like the following
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
if empty(&shellxquote)
let l:shxq_sav = ''
set shellxquote&
endif
let cmd = '"' . $VIMRUNTIME . '\diff"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
let cmd = substitute(cmd, '!', '\!', 'g')
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3
if exists('l:shxq_sav')
let &shellxquote=l:shxq_sav
endif
endfunction
set expandtab
set tabstop=4
set softtabstop=4
set shiftwidth=4
set autoindent
set textwidth=80
set guifont=Lucida Console\ 14
You have to escape spaces with a backslash. You've already done so for the space after "Console". You just need to also escape the one before "Console".
set guifont=Lucida\ Console\ 14
in _vimrc file:
set guifont=Lucida_Console:h14
This is not about hitting āpā when over the file name , but essentially having the same result by simply placing the cursor over it.
You can remap some motions to a function that populates the preview window according to the current word under the cursor.
Here's a basic example that handles text files and directories:
set nocompatible
set autochdir
" Previewed files are present in the current directory
let g:netrw_keepdir = 0
function! PreviewFile(...)
let l:wordUnderCursor = a:1
if !empty(glob(l:wordUnderCursor))
let l:type = system('file -ib ' . shellescape(l:wordUnderCursor))
if l:type =~# '^text/plain'
silent! execute 'pedit' l:wordUnderCursor
elseif l:type =~# '^inode/directory'
let l:name = tempname()
set noautochdir
silent! execute 'pedit! ' . l:name
wincmd P
normal! ggdG
silent! execute 'r !ls ' . l:wordUnderCursor
normal! ggdd
wincmd w
endif
endif
endfunction
autocmd FileType netrw
\ nnoremap j j:call PreviewFile(expand("<cWORD>"))<CR> |
\ nnoremap k k:call PreviewFile(expand("<cWORD>"))<CR>
I want a minimum way of using git blame from vim (I don't want to use the whole Fugitive plugin). What I have right now is this:
This function is from the vim help page and enables me to open shell commands in a scratch buffer.
function! s:ExecuteInShell(command)
let command = join(map(split(a:command), 'expand(v:val)'))
let winnr = bufwinnr('^' . command . '$')
silent! execute winnr < 0 ? 'botright new ' . fnameescape(command) : winnr . 'wincmd w'
setlocal buftype=nowrite bufhidden=wipe nobuflisted noswapfile nowrap number
echo 'Execute ' . command . '...'
silent! execute 'silent %!'. command
silent! execute 'resize ' . line('$')
silent! redraw
silent! execute 'au BufUnload <buffer> execute bufwinnr(' . bufnr('#') . ') . ''wincmd w'''
silent! execute 'nnoremap <silent> <buffer> <LocalLeader>r :call <SID>ExecuteInShell(''' . command . ''')<CR>'
echo 'Shell command ' . command . ' executed.'
endfunction
command! -complete=shellcmd -nargs=+ Shell call s:ExecuteInShell(<q-args>)
Together with the above function I would like to do:
noremap <leader>b :Shell git blame -L line(".") - 5, line(".") + 5 %<cr>
to get a git blame window for the rows around the cursor position in the current buffer.
Now I have two questions:
1: How can I make the scratch buffer that opens read-only so I can close it using only q? I would like to make this change in the function so that all: Shell commands can be closed with q.
2: How can i get line(".") - 5 expand into current line - 5 row number?
To make a buffer read-only and not modifiable, you can put
setlocal readonly nomodifiable
at the end of your function.
In the case of your next question, you can use execute and eval
noremap <leader>b :execute "Shell git blame -L " . eval(line(".")-5)) . ",+10 %"<cr>
I recommend to read these descriptions, and help in general:
:h execute
:h eval
:h readonly
:h nomodifiable
Also here is the link to the mentioned function on wikia.
I use a simple hack to get my vim git integration:
This solves my git commit/add , blame and op.
map <F5> :!git add %;git commit -m "commit" %<CR>
map <F3> :!git blame % > %.blame<CR>:vsplit %.blame<CR>
map <F4> :!git log --abbrev-commit % > %.log<CR>:vsplit %.log<CR>
i have something here, the script can be copied and added to the .vimrc file.
command Blame will run git blame on the current file, will split the screen and put the result of 'git blame -w' into the lower buffer (buffer is put into read only mode), your cursor will be in the blame buffer (current line as in source file)
while in the lower buffer: GShow will split the lower screen and open the commit 'git show -w [hash]' for the current line in the right hand buffer (buffer again in read only mode).
"======================================================
" Function runs git blame on file in current buffer and
" puts output into a new window
" move to current line in git output
" (can't edit output)
"======================================================
command! -nargs=* Blame call s:GitBlame()
function! s:GitBlame()
let cmdline = "git blame -w " . bufname("%")
let nline = line(".") + 1
botright new
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap
execute "$read !" . cmdline
setlocal nomodifiable
execute "normal " . nline . "gg"
execute "set filetype=cpp"
endfunction
"======================================================
" function runs git show on report of git blame;
" the first token of a line is taken as SHA checsum of the
" git commit
"======================================================
command! -nargs=* GShow call s:GitShowFromBlame()
function! s:GitShowFromBlame()
let curline = getline( "." )
let tokens = split(curline)
let cmdline = "git show -w " . tokens[0]
"botright new
"topleft new
"vsplit new
"vnew new
vertical new
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile nowrap
execute "$read !" . cmdline
setlocal nomodifiable
execute "normal 1gg"
execute "set filetype=cpp"
endfunction
My take on this
fun! GbSyncLines(is_ow2bw)
let l:ow = getbufvar(+expand('<abuf>'), 'origWindow')
let l:bw = getbufvar(+expand('<abuf>'), 'blameWindow')
let l:origLine=line('.', win_getid(l:ow))
let l:blameLine=line('.', win_getid(l:bw))
if a:is_ow2bw == 1
eval win_execute(win_getid(l:bw), "windo call cursor(" . l:origLine . ", 0)")
else
eval win_execute(win_getid(l:ow), "windo call cursor(" . l:blameLine . ", 0)")
endif
endfun
fun! GbMake(view, origWindow)
let l:origWindow=a:origWindow
let l:file_dir=expand('#'.winbufnr(a:origWindow).':h')
let l:file_name=expand('#'.winbufnr(a:origWindow).':t')
let l:origLine=line('.', win_getid(a:origWindow))
sil exe a:view
setl buftype=nofile bufhidden=wipe
exe "lcd ".l:file_dir
exe "0r ! git blame " . l:file_name
setl nomodifiable
setl nonumber norelativenumber
if v:shell_error != 0
exe l:origWindow . "wincmd w"
return
end
eval searchpos('(')
eval searchpairpos('(', '', ')')
norm! gE
exe "vertical resize " . col('.')
let l:blameWindow = winnr()
let b:blameWindow = winnr()
let b:origWindow = a:origWindow
let l:origLine=line('.', win_getid(b:origWindow))
eval cursor(l:origLine , 1)
nnoremap <buffer> <C-]> :call GcommitShow(expand("<cword>"), line(".")) <CR>
au BufWipeout <buffer> call win_execute(win_getid(getbufvar(+expand('<abuf>'), 'origWindow')), "windo setl scrollbind&")
au WinEnter <buffer> :call GbSyncLines(1)
au WinLeave <buffer> :call GbSyncLines(0)
setl scrollbind
exe a:origWindow . "wincmd w"
setl scrollbind
exe "syncbind"
if a:view == "enew"
exe l:blameWindow . "wincmd w"
end
endfun
fun! GcommitShowClose()
let l:w=getbufvar(expand('<abuf>'), 'origWindow')
let l:l=getbufvar(expand('<abuf>'), 'origLine')
let l:v=getbufvar(expand('<abuf>'), 'origView')
eval GbMake("enew", l:w)
eval winrestview(l:v)
eval cursor(l:l, 1)
endfun
fun! GcommitShow(commit, linenr)
let l:origWindow=b:origWindow
let l:viewsave=winsaveview()
sil exe "enew | setlocal buftype=nofile | setlocal bufhidden=wipe | 0r ! git show " . a:commit
setl nomodifiable
setl nonumber norelativenumber
if v:shell_error != 0
eval GbMake('enew', l:origWindow)
return
end
let b:origWindow=l:origWindow
let b:origLine=a:linenr
let b:origView=l:viewsave
nnoremap <buffer> <C-O> :call GcommitShowClose()<CR>
eval cursor(1, 1)
endfun
fun! Gb()
eval GbMake('vnew', winnr())
endfun
command! Gb call Gb()
while in the blame window, CTRL+] shortcut will show git show for commit the cursor is on. Then CTRL+O will get back to the git blame.
Note lcd on start - command will work even when you are not in the git dir. The gist
For instance, if I write <?ph
The following words may pop up (and php is highlighted in the menu but not displayed in the code):
php
phrase
phrases
If I hit Tab or CTRL + N it just goes "Back at original."
If I press Shift + Tab or CTRL + P it goes to phrase.
While php is highlighted in the menu, If I press enter ph doesn't get completed.
I'm not sure if this is a normal behaviour in Vim or something wrong with my .vimrc:
" SHORTCUTS
nnoremap <F4> :set filetype=html<CR>
nnoremap <F5> :set filetype=php<CR>
nnoremap <F3> :TlistToggle<CR>
" press space to turn off highlighting and clear any message already displayed.
nnoremap <silent> <Space> :nohlsearch<Bar>:echo<CR>
" set buffers commands
nnoremap <silent> <M-F8> :BufExplorer<CR>
nnoremap <silent> <F8> :bn<CR>
nnoremap <silent> <S-F8> :bp<CR>
" open NERDTree with start directory: D:\wamp\www
nnoremap <F9> :NERDTree /home/alex/www<CR>
" open MRU
nnoremap <F10> :MRU<CR>
" open current file (silently)
nnoremap <silent> <F11> :let old_reg=#"<CR>:let #"=substitute(expand("%:p"), "/", "\\", "g")<CR>:silent!!cmd /cstart <C-R><C-R>"<CR><CR>:let #"=old_reg<CR>
" open current file in localhost (default browser)
nnoremap <F12> :! start "http://localhost" file:///"%:p""<CR>
" open Vim's default Explorer
nnoremap <silent> <F2> :Explore<CR>
nnoremap <C-F2> :%s/\.html/.php/g<CR>
"
set completeopt=menu,preview,longest
" REMAPPING
" map leader to ,
let mapleader = ","
" remap ` to '
nnoremap ' `
nnoremap ` '
" remap increment numbers
nnoremap <C-kPlus> <C-A>
" COMPRESSION
function Js_css_compress ()
let cwd = expand('<afile>:p:h')
let nam = expand('<afile>:t:r')
let ext = expand('<afile>:e')
if -1 == match(nam, "[\._]src$")
let minfname = nam.".min.".ext
else
let minfname = substitute(nam, "[\._]src$", "", "g").".".ext
endif
if ext == 'less'
if executable('lessc')
cal system( 'lessc '.cwd.'/'.nam.'.'.ext.' &')
endif
else
if filewritable(cwd.'/'.minfname)
if ext == 'js' && executable('closure-compiler')
cal system( 'closure-compiler --js '.cwd.'/'.nam.'.'.ext.' > '.cwd.'/'.minfname.' &')
elseif executable('yuicompressor')
cal system( 'yuicompressor '.cwd.'/'.nam.'.'.ext.' > '.cwd.'/'.minfname.' &')
endif
endif
endif
endfunction
autocmd FileWritePost,BufWritePost *.js :call Js_css_compress()
autocmd FileWritePost,BufWritePost *.css :call Js_css_compress()
autocmd FileWritePost,BufWritePost *.less :call Js_css_compress()
" GUI
" taglist right side
let Tlist_Use_Right_Window = 1
" hide tool bar
set guioptions-=T
"remove scroll bars
set guioptions+=LlRrb
set guioptions-=LlRrb
" set the initial size of window
set lines=46 columns=180
" set default font
set guifont=Monospace
" set guifont=Monospace\ 10
" show line number
set number
" set default theme
colorscheme ir_dark
" encoding
set encoding=utf-8
setglobal fileencoding=utf-8 bomb
set fileencodings=ucs-bom,utf-8,latin1
" SCSS syntax highlight
au BufRead,BufNewFile *.scss set filetype=scss
" LESS syntax highlight
syntax on
au BufNewFile,BufRead *.less set filetype=less
" Haml syntax highlight
"au! BufRead,BufNewFile *.haml
"setfiletype haml
" Sass syntax highlight
"au! BufRead,BufNewFile *.sass
"setfiletype sass
" set filetype indent
filetype indent on
" for snipMate to work
filetype plugin on
" show breaks
set showbreak=----->
" coding format
set tabstop=4
set shiftwidth=4
set linespace=1
" CONFIG
" keep the buffer around when left
set hidden
" enable matchit plugin
source $VIMRUNTIME/macros/matchit.vim
" folding
set foldmethod=marker
set foldmarker={,}
let g:FoldMethod = 0
map <leader>ff :call ToggleFold()<cr>
fun! ToggleFold()
if g:FoldMethod == 0
exe 'set foldmethod=indent'
let g:FoldMethod = 1
else
exe 'set foldmethod=marker'
let g:FoldMethod = 0
endif
endfun
" save and restore folds when a file is closed and re-opened
"au BufWrite ?* mkview
"au BufRead ?* silent loadview
" auto-open NERDTree everytime Vim is invoked
au VimEnter * NERDTree /home/alex/www
" set omnicomplete
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType php set omnifunc=phpcomplete#CompletePHP
autocmd FileType c set omnifunc=ccomplete#Complete
" Improve completion popup menu
inoremap <expr> <Esc> pumvisible() ? "\<C-e>" : "\<Esc>"
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<CR>"
inoremap <expr> <Down> pumvisible() ? "\<C-n>" : "\<Down>"
inoremap <expr> <Up> pumvisible() ? "\<C-p>" : "\<Up>"
inoremap <expr> <PageDown> pumvisible() ? "\<PageDown>\<C-p>\<C-n>" : "\<PageDown>"
inoremap <expr> <PageUp> pumvisible() ? "\<PageUp>\<C-p>\<C-n>" : "\<PageUp>"
" Remove trailing white-space once the file is saved
au BufWritePre * silent g/\s\+$/s///
" Use CTRL-S for saving, also in Insert mode
noremap <C-S> :update!<CR>
vnoremap <C-S> <C-C>:update!<CR>
inoremap <C-S> <C-O>:update!<CR>
" DEFAULT
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
"source $VIMRUNTIME/mswin.vim
"behave mswin
" disable creation of swap files
set noswapfile
" no back ups wwhile editing
set nowritebackup
" disable creation of backups
set nobackup
" no file change pop up warning
autocmd FileChangedShell * echohl WarningMsg | echo "File changed shell." | echohl None
set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let eq = ''
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
let cmd = '""' . $VIMRUNTIME . '\diff"'
let eq = '"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction
Is there a way to choose the first word immediately?
EDIT:
:map <c-y> says:
n <C-Y>A <Plug>ZenCodingAnchorizeSummary
n <C-Y>a <Plug>ZenCodingAnchorizeURL
n <C-Y>k <Plug>ZenCodingRemoveTag
n <C-Y>j <Plug>ZenCodingSplitJoinTagNormal
n <C-Y>/ <Plug>ZenCodingToggleComment
n <C-Y>i <Plug>ZenCodingImageSize
n <C-Y>N <Plug>ZenCodingPrev
n <C-Y>n <Plug>ZenCodingNext
v <C-Y>D <Plug>ZenCodingBalanceTagOutwardVisual
n <C-Y>D <Plug>ZenCodingBalanceTagOutwardNormal
v <C-Y>d <Plug>ZenCodingBalanceTagInwardVisual
n <C-Y>d <Plug>ZenCodingBalanceTagInwardNormal
n <C-Y>; <Plug>ZenCodingExpandWord
n <C-Y>, <Plug>ZenCodingExpandNormal
v <C-Y>, <Plug>ZenCodingExpandVisual
Use ctrl-y to select the currently highlighted option in the list. ctrl-n and p will go through the list next/previous, but y will select current.
In your .vimrc you have added "longest" to the completeopt option:
set completeopt=menu,preview,longest
This means that omni completion can only fill in the longest common substring of all possible matches. If you just use :set completeopt=menu,preview then vim should select the first match when using omni completion.