Skip to content

aaronspring/cdo_lazy_vim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

in progress...

CDO_lazy_vim README

If you are using vi/vim/gvim for scripting with cdo, you can sometimes hardly remember cdo commands or you are just too lazy to type out "sellonlatbox" all the time, this might be something for you.

animation Configuration instructions

For completion:

  1. Copy dictionary file ".vim/dictionary/cdo.dic" to "~/.vim/dictionary"
  2. Copy all desired variable dictionary files "*.dic" from this repositories ".vim/dictionary" to "~/.vim/dictionary"
  3. Copy the file ".vim/ftdetect/cdo.vim" to "~/.vim/ftdetect" to name the dictionaries that should be associated with a certain filetype. Default: cdo.dic associated with *.sh
  4. Add the following lines to your .vimrc file "~/.vimrc" to include dictionaries for completions
set complete+=k
set completeopt=longest,menuone

Optional completion:

  1. If you wish some dictionaries, eg. those for other model variables just comment those in in".vim/ftdetect/cdo.vim"
  2. If you want to use <Tab> for auto-completion like in your shell, add those lines to your .vimrc
" Use TAB to complete when typing words, else inserts TABs as usual.
" Uses dictionary and source files to find matching words to complete.
" "See help completion for source,
" Note: usual completion is on <C-n> but more trouble to press all the time.
" Never type the same word twice and maybe learn a new spellings!
" Use the Linux dictionary when spelling is in doubt.
" Window users can copy the file to their machine.
function! Tab_Or_Complete()
  if col('.')>1 && strpart( getline('.'), col('.')-2, 3 ) =~ '^\w'
    return "\<C-N>"
  else
      return "\<Tab>"
  endif
endfunction
:inoremap <Tab> <C-R>=Tab_Or_Complete()<CR>

Source: http://vim.wikia.com/wiki/Smart_mapping_for_tab_completion
The usual <Tab> command will still be executed when no completion is feasable, eg. in the beginning of (empty) lines
3. If you fancy other auto-completion setting, play with the line

set complete=longest,menuone

The current setting completes up to the last common string and then shows a menu. Other options are listed in the vim help or http://vimdoc.sourceforge.net/htmldoc/options.html#'completeopt'



For syntax highlighting:

  1. coming soon

Operating instructions

Start typing your desired cdo command and hit <Control-N>

cdo sell<Ctrl-N>

Get the following autocompletion options

sellevel                /..path..to..dic-file/cdo.dic
sellevidx               /..path..to..dic-file/cdo.dic
sellonlatbox            /..path..to..dic-file/cdo.dic
selltype                /..path..to..dic-file/cdo.dic

Hit another <Ctrl-N> go get the first shown match

cdo sellevel

Hit another <Ctrl-N> to choose the next match or move down with arrow keys and hit for your choice

Copyright and licensing information

  • helpme

Known bugs

  • just starting
  • list of dictionary items might be incomplete

Contact information

Aaron Spring
Bundesstraße 53
ZMAW Room 229
aaron.spring@mpimet.mpg.de

Looking forward to receiving your questions, comments or wishes

Changelog

  • 0.1: basic auto-complete function based on cdoCompletion.bash as of 2016/09/06
  • 0.2: some MPI-ESM variables included for HAMOCC: 2d, 3d and sediment; MPIOM: 2d, 3d and ECHAM6: BOT, LOG, ...; checkout this repositories ".vim/dictionary"

Dictionary Versions

on stored on mistral:/work/mh1007/mpiesm1/experiments/

Working on

  • proper syntax highlighting
  • more description in completion popup, eg. syntax or variable longname
  • anything else needed?

Credits and acknowledgements

  • Uwe Schulzweida, creator of cdo
  • Prince K Xavier, the dude who setup auto-completion for NCL and made me think about this