Still using vi for Ansible? No problem!
Having grown up using vi as a main editor on UN*X systems, I still love it and often fire it up for quick demos etc. I can't think of any other software so long lived, loved and effective still!
I sometimes get asked for tips and tricks for using vi/vim for writing Ansible. I never got round to formally writing anything up, until now :)
Vi can be customised through a .vimrc config file.
I came across a cracking guide by Doug Black which covers all the bases and more. I recommend reading this to see if there's any other settings which could be useful for you.
Here's my config:
cat ~/.vimrc " cracking guide at https://dougblack.io/words/a-good-vimrc.html set tabstop=2 " a tab = 2 spaces set softtabstop=2 " no. spaces on backspace set expandtab " turn tabs into spaces set autoindent " autoindent! set wildmenu " autocomplete for filenames set showmatch " parenthesis matching syntax on " syntax! colorscheme default " add a little colour to our live set incsearch " search as chars entered set hlsearch " highlight matches let mapleader="," " leader is a comma nnoremap <leader><space> :nohlsearch<CR> " leader,space disables search highlighting
Most of this should be self explanatory I hope. It is also available here
Enjoy.
I would also create a temporary directory for swap files (e.g. ~/.vim/tmp) and set the Working Directory for Vim to this directory in .vimrc : set directory^=$HOME/.vim/tmp/ This prevents vim's .swp files being created in the Git repo's you are working in.
Still my primary editor! The vim plugins for graphical editors just aren’t the same.
Nice one Phil Griffiths, I'll give some of these a try.