## Installing and setting up the Vim text editor

To write LaTeX files, I use GVim which is basically Vim with a modern outlook. If you are interested to get a good text editor, use Vim or GVim with free Unix operating systems (that is to say operating systems which are under GPL or BSD license), MacVim with Mac OSX, and maybe GVim or Evim with Microsoft Windows operating systems (XP, Vista, Seven).

If you make some researches about text editors, you may notice that there is a stupid “war” between Emacs and Vim. Actually, both are excellent text editors, only the approach changes. Also, though comparing a text editor might be highly controversial and subjective, it might be right to say that Vim is one of the best text editors, available for all platforms.

If you wish to write LaTeX files, a well configured text editor like GVim will make your life easier, and will increase your efficiency in typesetting. Once you will have learned how to use Vim, you will also understand how ridiculous are Word processors like Microsoft Word or OpenOffice.org Writer compared to Vim or Emacs.

In this post I will explain, first, how to install Vim in GNU/Linux, FreeBSD, Microsoft Windows and Mac OSX, and secondly, I will write a short explanation of my setup.

1. For GNU/Linux To install GVim with GNU/Linux, the version of Vim with a modern interface, you have 2 choices. (1) To install it with your package manager. If you have Ubuntu, install Vim-gtk with Ubuntu Software Center :

(2) Th second choice is to install GVim from the official website, useful if you want the latest version of Vim (currently, 7.3) :
http://ftp.vim.org/pub/vim/unix/
Download the latest version, at the bottom of the page. Notice that to install it with Ubuntu, you will need some development libraries, such as libx11-dev, libgtk2.0-dev and another one but I don’t remember (look at the compilation errors, or the INSTALL* file). So if you are not familiar with command line and compilation errors, I recommend to use your package manager instead of the tarball file of the official website.
2. For FreeBSD To install GVim with FreeBSD, you could choose the second way I have described above for GNU/Linux, or to install it from ports (notice that the install process with ports is quite long thanks to patches) :
 su cd /usr/ports/editors/vim make WITH_GTK2=yes make install clean 
3. For Microsoft Windows Though I am not really aware of the install process with any version of Windows (I have never used Windows on my laptop), I suppose you will have to install and download it from the following url :
4. For Mac OSX I don’t have tried to install Vim on Mac OSX, but try the following link :
http://macvim.org/OSX/index.php

Secondly, you have to make Vim work like you want. Indeed, you won’t be efficient with Vim if you don’t have a good setup. Since I have already done the job (thanks to all informations I have gathered from the internet), you will just have to make a copy of my git repository. To do so, you will need to install git if you don’t have it. If you are not familiar with the command line and use Ubuntu, copy-paste the following in a terminal (to open a terminal, press “ctrl+alt+t”) :
 cd ~ sudo apt-get install git git https://alexandre-k@github.com/alexandre-k/repository_alexandre_krispin.git cp ~/repository_alexandre_krispin/configuration_files_for_text_editors/vim_configuration_files/.vim ~/.vim cp ~/repository_alexandre_krispin/configuration_files_for_text_editors/vim_configuration_files/.vimrc ~/.vimrc cp ~/repository_alexandre_krispin/configuration_files_for_text_editors/vim_configuration_files/.gvimrc ~/.gvimrc 
That’s all. Notice that I don’t have used my setup with Mac OSX and Windows, and I don’t know if I will be able to help you if you have any troubles with Windows.

Now I will explain my .vimrc, my .gvimrc and then my tex.vim (located in .vim/ftplugin/) :

1. First, my .vimrc (located in /home/your_username/.vimrc in free Unix operating systems like GNU/Linux and *BSD). You can take a look at it in my Github repository :

“————————————————————————-
” Basic settings for LaTeXsuite
http://vim-latex.sourceforge.net/documentation/latex-suite/recommended-settings.html
“————————————————————————-
” REQUIRED. This makes vim invoke Latex-Suite when you open a tex file.
filetype plugin on

This setting will allow you to get the right settings according to the file extension. In other words, it will load all settings used with LaTeX-suite.

” IMPORTANT: win32 users will need to have ‘shellslash’ set so that latex
” can be called correctly.
“set shellslash

” IMPORTANT: grep will sometimes skip displaying the file name if you
” search in a singe file. This will confuse Latex-Suite. Set your grep
” program to always generate a file-name.
set grepprg=grep\ -nH\ $* ” OPTIONAL: This enables automatic indentation as you type. filetype indent on ” OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to ” ‘plaintex’ instead of ‘tex’, which results in vim-latex not being loaded. ” The following changes the default filetype back to ‘tex’: let g:tex_flavor=’latex’ “To jump from a section to another one map ]s :/\\$$sub$$\{,2}section\s*{ :noh map [s :?\\$$sub$$\{,2}section\s*{ :noh This part is just a copy of the recommended settings from the official website of Latex-suite. “———————————————————————— ” General settings “———————————————————————— let b:loaded_tex_autoclose = 1 let g:autoclose = 1 set backspace=indent,eol,start “allow backspacing over everything in insert mode set textwidth=80 set title ” change the terminal’s title syntax on “switch on syntax highlight set undolevels=1000 “number of undos set history=1000” “sets how many lines of history VIM has to remember set complete+=k ” enable dictionary completion set clipboard+=unnamed ” yank and copy to X clipboard set showmatch “show pairs of brackets set hlsearch ” When there is a previous search pattern, highlight all ” its matches. set incsearch ” While typing a search command, show immediately where the ” so far typed pattern matches. set ignorecase ” Ignore case in search patterns. set smartcase ” Override the ‘ignorecase’ option if set wrapscan ” end of search has been achieved! set magic “regexp version magic set cursorline “highlight current line set cursorcolumn “highlight current column set wildmenu set wildignore=*.o,*~,*.cmo,*.cmi,*.a,*.cmx,*.cmxa,*.lo,*.log,*.aux,*.dvi,*.aut,*.aux,*.bbl,*.blg,*.dvi,*.fff,*.out,*.pdf,*.ps,*.toc,*.ttt set number “to show line number “set nocompatible “seems that setting Vim not to be compatible with Vi disables the setting bellow, whichwrap. “Therefore I disable it set whichwrap=b,s,,[,] ” Allow specified keys that move the cursor left/right ” to move to the previous/next line when the cursor is on the first/last character ” in the line. b (backspace), s (space) and the arrows. set nostartofline ” Do not place the cursor at the start of the line when using Page up/down. set suffixes=.bak,~,.swp,.o,.info,.aux,.log,.dvi,.bbl,.blg,.out,.toc “for file names completion set hi=2000 ” remember last 2000 typed commands set autoread ” Set to auto read when a file is changed from the outside set enc=utf-8 set hidden ” It hides buffers instead of closing them. This means that you ” can have unwritten changes to a file and open a new file using :e, without being ” forced to write or undo your changes first. Also, undo buffers and marks are ” preserved while the buffer is open. set visualbell ” don’t beep set noerrorbells ” don’t beep set list ” Vim can highlight whitespaces for you in a convenient way: set listchars=tab:>.,trail:.,extends:#,nbsp:. set laststatus=2 “status bar set statusline=%n:\ %f%m%r%h%w\ [%Y,%{&fileencoding},%{&fileformat}]\ [%l-%L,%v][%p%%]\ [%{strftime(\”%l:%M:%S\ \%p,\ %a\ %b\ %d,\ %Y\”)}] set ruler set rulerformat=%25(%n%m%r:\ %Y\ [%l,%v]\ %p%%%) ” toujours afficher le mode courant set showcmd “show the command being typed Then come the general settings. Since they are well commented, I let you read by yourself. To sum up, I have put here some settings about the text width, the search, the cursor, the status line, and other stuff for convenience that you can find everywhere on the internet. “—————————————– ” change cursor colour depending upon mode if exists(‘&t_SI’) let &t_SI = “\]12;lightgoldenrod\x7” let &t_EI = “\]12;grey80\x7” endif “——————————– ” Backups “——————————– set nobackup set backupcopy=auto set backupskip=/tmp/*,$TMPDIR/*,$TMP/*,$TEMP/*,*test*,*temp*,*tmp*,*tst*,*~,*bak

“———————————–
“nice colors and fonts
“———————————–
colorscheme herald
colors herald
“set guifont=DejaVu\ Sans\ Mono\ 10
set guifont=Inconsolata\ 12 ” very nice, but leaves terrible artefacts with national (mostly russian) characters
“set guifont=Terminus\ 10 ” wonderful, yet smallish, and sucks at larger sizes
“———————————-
” GUI Options
“———————————-
“if has(“gui_running”)
” ” GUI cursor: no blinking

” ” no toolbar
” set guioptions-=T
” ” no autoselect
” set guioptions-=a

” ” Use console messages instead of GUI dialogs
” set guioptions+=c
“endif

The most important thing here is the settings for backups. Since backup files annoyed me, I have set it to “nobackup”. If you prefer to get backup, replace “set nobackup” by “set backup”. Also, the color scheme is “herald”, a nice one, and the font is inconsolata. If you prefer to get a more shiny or simply another color scheme you would like, check the demos at the following url :
Color sampler pack
Or this one :
Color samples with LaTeX files
Once you have chosen, replace the “herald” colorscheme by the one you want.

“——————
“formatting
“——————
set formatoptions=tcroqn ” see help
“set formatoptions=c,q,r,t ” This is a sequence of letters which describes how
” automatic formatting is to be done.

” letter meaning when present in ‘formatoptions’
” —— —————————————
” c Auto-wrap comments using textwidth, inserting
” the current comment leader automatically.
” q Allow formatting of comments with “gq”.
” r Automatically insert the current comment leader
” after hitting in Insert mode.
” t Auto-wrap text using textwidth (does not apply
“—————
set smartindent ” turn on smart indenting
set autoindent ” always set autoindenting on
set copyindent ” copy the previous indentation on autoindenting
set shiftwidth=4 ” number of spaces to use for autoindenting
set shiftround ” use multiple of shiftwidth when indenting with ‘<‘ and ‘>’
set smarttab ” insert tabs on the start of a line according to
” shiftwidth, not tabstop
“setlocal indentkeys+=},=\\item,=\\bibitem,=\\else,=\\fi,=\\or,=\\]

“————————–
” indentation automatique (à la Emacs)
“vnoremap =$“vnoremap = “nnoremap =$
“nnoremap mzvip=z

“let g:tex_indent_items = 1

Here are settings to make formatting work… But it doesn’t work well for LaTeX files, I am sorry for the inconvenience. Since I don’t really need to format LaTeX files (I write it correctly), I don’t really care of this. If one day I receive files badly formatted, then I will try to make it work. However, if you just plan to write LaTeX files, then the current settings might be sufficient.

“—————————-
“TAB BAR
“—————————-
” set up tab labels with tab number, buffer name, number of windows
function! GuiTabLabel()
let label = ”
let bufnrlist = tabpagebuflist(v:lnum)

” Add ‘+’ if one of the buffers in the tab page is modified
for bufnr in bufnrlist
if getbufvar(bufnr, “&modified”)
let label = ‘+’
break
endif
endfor

” Append the tab number
let label .= tabpagenr().’: ‘

” Append the buffer name
let name = bufname(bufnrlist[tabpagewinnr(v:lnum) – 1])
if name == ”
” give a name to no-name documents
if &buftype==’quickfix’
let name = ‘[Quickfix List]’
else
let name = ‘[Not yet saved]’
endif
else
” get only the file name
let name = fnamemodify(name,”:t”)
endif
let label .= name

” Append the number of windows in the tab page
let wincount = tabpagewinnr(v:lnum, ‘$’) return label . ‘ [‘ . wincount . ‘]’ endfunction ” set up tab tooltips with every buffer name function! GuiTabToolTip() let tip = ” let bufnrlist = tabpagebuflist(v:lnum) for bufnr in bufnrlist ” separate buffer entries if tip!=” let tip .= ‘ | ‘ endif ” Add name of buffer let name=bufname(bufnr) if name == ” ” give a name to no name documents if getbufvar(bufnr,’&buftype’)==’quickfix’ let name = ‘[Quickfix List]’ else let name = ‘[Not yet saved]’ endif endif let tip.=name ” add modified/modifiable flags if getbufvar(bufnr, “&modified”) let tip .= ‘ [+]’ endif if getbufvar(bufnr, “&modifiable”)==0 let tip .= ‘ [-]’ endif endfor return tip endfunction set guitablabel=%!GuiTabLabel() set guitabtooltip=%!GuiTabToolTip() Here are settings for the tab bar. Notice that for some Vim users, it seems to be a kind of pride an joy, but you can get tab bars with Emacs, Kile, and other softwares. “————– “spelling… “————– “to enable spell checking by default, uncomment the following line, “set spell ” automatic spell checking in your language for .txt et .tex. Replace “fr” by your default ” language, “en” if english : “augroup filetypedetect “au BufNewFile,BufRead *.txt setlocal spell spelllang=fr “au BufNewFile,BufRead *.tex setlocal spell spelllang=fr “augroup END “———————————— ” painless spell checking ” for French, you’ll need ” wget http://ftp.vim.org/pub/vim/runtime/spell/fr.utf-8.sug ” wget http://ftp.vim.org/pub/vim/runtime/spell/fr.utf-8.spl ” which you may move into ~/.vim/spell “————————————- function s:spell_fr() if !exists(“s:spell_check”) || s:spell_check == 0 echo “Spell checking activated (french)” let s:spell_check = 1 setlocal spell spelllang=fr else echo “Spell checking canceled” let s:spell_check = 0 setlocal spell spelllang= endif endfunction ” for English function s:spell_en() if !exists(“s:spell_check”) || s:spell_check == 0 echo “Spell checking activated (english)” let s:spell_check = 1 setlocal spell spelllang=en else echo “Spell checking canceled” let s:spell_check = 0 setlocal spell spelllang= endif endfunction “See mapping for spell checking in the relevant section, l. 361 “——–Another trick for spell checking is the following line : “uncomment if you want to use it, type “,C” if you want to enable it, “and replace aspell by any other dictionary you use (ispell, hunspell) “map ,C :w:!aspell -c %:e %” Here are settings for spell checking. If you want to enable spell checking by default, there are several ways. One is to uncomment the lines : ""augroup filetypedetect "au BufNewFile,BufRead *.txt setlocal spell spelllang=fr "au BufNewFile,BufRead *.tex setlocal spell spelllang=fr "augroup END" and to replace “fr” by “en” or any other abbreviation depending on the language you use. “————————— “For tags, but doesn’t work let tlist_tex_settings = ‘latex;s:sections;g:graphics;l:labels’ let tlist_make_settings = ‘make;m:makros;t:targets’ Here was a rest of the period when I tried to set up tags for LaTeX files, but didn’t get it successfully working. And since I don’t care and don’t have time for it, I let it for better days. “———————————————————————— ” MAPPING “———————————————————————— “—————————- “Saving “————————— map :w imap :w “—————————— ” Terminal “—————————— map :!gnome-terminal & imap :!gnome-terminal & “——————————- ” Graphical file manager “——————————– map :!nautilus & map :!nautilus & “—————————- “Exit “—————————- “exit map :q imap :q “exit all map :qall imap :qall “force Exit map :qall! imap :qall! “—————————- “Mapping to activate file explorer “of the specified directory “—————————- “To display NERDTree nnoremap :NERDTree /home/freeman/ ” To display VimExplorer nmap :VE %:p:h “—————————- “Mapping to explorer of recent file, “Most recently used files “—————————- map :Mru imap :Mru “————- “SelectBuf “————- nmap SelectBuf noremap SelBufHelpKey “—————————– “Compiling and viewing its .tex file “with XeLaTeX and evince (set in tex.vim) “—————————– “Compile and start viewer map ;ll ;lv imap ;ll ;lv “Compile only map ;ll imap ;ll “————————– “To enable spell checking for french : noremap :call spell_fr() inoremap :call spell_fr() vnoremap :call spell_fr() ” and for english : noremap :call spell_en() inoremap :call spell_en() vnoremap :call spell_en() Here are settings related to F* keys. I will explain their use latter, though you might be able to undestand it easily by yourself thanks to comments. Notice that if you don’t use gnome-terminal as terminal and nautilus as file manager, you will have to change the settings (if you don’t understand what I am talking about and use Ubuntu, then don’t worry and don’t change anything). “——————————— “Ctrl+Insert to copy into clipboard “Shift+Insert to paste from clipboard “Shift+Delete to cut into clipboard “Ctrl+a to select all “—————————- nmap “+gP imap i vmap “+y map ggVG map “+x “—————————- “Mapping to desactivate highligting “of search results “—————————- nnoremap :noh “——————————– ” firefox like shorcuts “——————————– map :tabnew map :tabnext map :tabprevious map :e “——————————– ” Quickly edit/reload the vimrc file “——————————- nmap ev :e$MYVIMRC
nmap sv :so $MYVIMRC “——————————– ” Use Q for formatting the current paragraph (or selection) “——————————– vmap Q gq nmap Q gqap “——————————– “If you like long lines with line wrapping enabled “——————————– nnoremap j gj nnoremap k gk “——————————– ” unmap arrows/pgdn/pgup so you learn to use hjkl map \ map \ map \ map \ map \ map \ imap imap imap imap imap imap “——————————– “Tired of clearing highlighted searches ? “——————————– nmap ,/ :nohlsearch “——————————– “Will search the word in firefox where “the cursor is when typing g in visual mode “big thanks to http://la.firme.perso.esil.univmed.fr/website/article.php3?id_article=70 vmap f :!firefox “http://www.google.fr/search?hl=fr&q=&btnG=Recherche+Google&meta=&#8221; >& /dev/null “A similar behaviour but for Wikipedia vmap w :!firefox “http://en.wikipedia.org/wiki/&#8221; >& /dev/null “——————————– “For qwerty keyboards : instead of “pressing “shift”+”;”, you will just “have to press ;, and say w to save. “——————————- “nnoremap ; : “——————————– “when you forgot to sudo before editing a file that requires root privileges “(typically /etc/hosts). This lets you use w!! to do that after you opened the “file already “——————————– cmap w!! w !sudo tee % >/dev/null Here are other settings to easily copy, paste, etc. Notice that I have disable arrow keys to force beginners to use hjkl keys. “—————————————————————— ” MiSCELLANOUS “—————————————————————— “——————————————————– ” Go back where I left off autocmd BufReadPost * call RestoreCursorPos() autocmd BufWinEnter * call OpenFoldOnRestore() ” Restore my cursor position function! RestoreCursorPos() if expand(“:p:h”) !=?$TEMP
if line(“‘\””) > 1 && line(“‘\””) <= line(“$”) let line_num = line(“‘\””) let b:doopenfold = 1 if (foldlevel(line_num) > foldlevel(line_num – 1)) let line_num = line_num – 1 let b:doopenfold = 2 endif execute line_num endif endif endfunction ” Open the fold if restoring cursor position function! OpenFoldOnRestore() if exists(“b:doopenfold”) execute “normal zv” if(b:doopenfold > 1) execute “+”.1 endif unlet b:doopenfold endif endfunction “————————- ” 日本語入力に関する設定: if has(‘multi_byte_ime’) || has(‘xim’) ” IME ON時のカーソルの色を設定(設定例:紫) highlight CursorIM guibg=Purple guifg=NONE ” 挿入モード・検索モードでのデフォルトのIME状態設定 set iminsert=0 imsearch=0 if has(‘xim’) && has(‘GUI_GTK’) ” XIMの入力開始キーを設定: ” 下記の s-space はShift+Spaceの意味でkinput2+canna用設定 “set imactivatekey=s-space endif ” 挿入モードでのIME状態を記憶させない場合、次行のコメントを解除 “inoremap :set iminsert=0 endif ” 日本語入力用のkeymapの設定例 (コメントアウト) “if has(‘keymap’) ” ” ローマ字仮名のkeymap ” “silent! set keymap=japanese set iminsert=0 imsearch=0 ” 入力時の初期状態 = IME OFF “endif Finally, here are settings to restore the position when you open again your file, and some settings to use ibus with japanese. Unfortunatly, it seems ibus conflicts with Latex-suite, and I don’t have time to search where does the problem come from. Since I don’t expect to write japanese files at the moment, I won’t search a solution until I have time. But if you can use ibus with GVim, then comments are welcome. 2. Secondly, here are my settings for .gvimrc. You can find it in my repository at Github : ” ウインドウの幅 set columns=200 ” ウインドウの高さ set lines=150 “set guioptions+=c ” use console dialogs, not the gui ones set guioptions-=T ” don’t show the toolbar set guioptions-=m ” don’t show the menu set guioptions-=r ” don’t need right scrollbar set guioptions-=L ” don’t show left scrollbars Basically, it will allow you to get a bigger window at startup than the default one, and it will disable useless things like scrollbars. 3. Thirdly, I will present my tex.vim file, that you can also find in my repository at Github : “————————————————————————– ” General settings “————————————————————————– “let g:autoclose = 1 “let g:Tex_SmartKeyQuote = 1 setlocal efm+=%E%f:%l:\ %m let g:Tex_DefaultTargetFormat=’pdf’ let g:Tex_CompileRule_pdf=’/usr/local/texlive/2010/bin/i386-linux/xelatex$*’

let g:Tex_ViewRule_dvi = ‘xdvi’
let g:Tex_ViewRule_ps = ‘gv’
let g:Tex_ViewRule_pdf = ‘evince’

Here are some settings to make Vim call the correct software related to the corresponding output. So for *.dvi files, I use xdvi, for *.ps files, gv, and for *.pdf files, evince. If you use other softwares, then replace the settings accordingly. If you use Ubuntu, then don’t do anything.

“———————————
“Enhanced Vim formatting of LaTeX files
“———————————
“map \gq ?^$\\|^\s*$$\\begin\\|\\end\\|\\label\\|\\documentclass\\|\\usepackage\\|\\paragraph\\item$$?1gq//+1 “omap lp ?^$\\|^\s*$$\\begin\\|\\end\\|\\label$$?1//-1.

“”To format LaTeX files,

“———————
“Dictionaries
autocmd Filetype tex,latex :set dictionary=~/.vim/ftplugin/latex-suite/dictionaries/dictionary,/home/linux/.vim/spell

Here are other rests from the period when I tried to setup a correct formatting with Vim for LaTeX files. Also, there is the settings for dictionaries, which are located in my home directory, ~/ (the abbreviation of /home/your_username).

“———————————————————————-
” Abbreviations
“———————————————————————-
iab ds dans
iab bcp beaucoup
iab qqn quelqu’un
iab qqc quelque chose
iab pol politique
iab leurope l’Europe
iab tv télévision
iab ceca CECA
iab ue Union Européenne
iab CE Commission Européenne
iab AL Amérique Latine
iab letat l’État
iab socio sociologie
iab éco économie
iab math mathématique
iab xelatex \XeLaTeX
iab latex \LaTeX
iab ak Alexandre Krispin

Here are settings for abbreviations. Remove them if you don’t use it. Also, notice that since the abbreviations are in the file “tex.vim” (~/.vim/ftplugin/tex.vim), they won’t be available for other files. If you want to make your abbreviations available for all files (.txt, .tex, .sty, etc), then copy your’s in the file .vimrc.

“—————————————————————————
” MAPPING
“—————————————————————————

“——————————–
“Change the mapleader from \ to ,

“——————————–
“fixing of é letter :
imap it
Tex_InsertItemOnThisLine
imap
Tex_MathBF
imap
Tex_MathCal
imap
Tex_LeftRight

“—————————————
“Another shortcut for placeholders.
“The default one is ctrl+j, really
“annoying. Pressing shift+tab is easier
imap
IMAP_JumpForward

“—————————————
“useful imaps
imap ,ja {\ja
“the above imap is intended to work with
“my setup for japanese in my templates compiled
“with XeLaTeX. For more details, look at my
“blog : https://alexkrispin.wordpress.com/
imap … \ldots

“———————————
“autoclose brackets
“Actually you can get a similar
“behavior with snippets : just type (,
“and then press the tab key. In case
“you prefer snippets, comment the
“following 3 lines
imap { {}
imap ( ()
imap [ []

“—————————————
“With XeLaTeX, these imaps are no longer
“required since you compile with
“unicode. In case you use pdfLaTeX to
“compile, enable the following :
“imap « \og
“imap » \fg
“imap € \EUR
“imap ~ \$\sim\
“imap ” \textquotedblleft
“imap ¢ \textquotedblright\

“————————————–
“If you have a french keyboard, this setting
“will let you easily put, let say bf.
“Instead of inserting bf in normal mode
“you will just have to insert ,bf (therefore,
“no need of the Alt Gr key)
vmap ,

Finally, I have set up my mappings :

• since I use an azerty keyboard, I have changed the map leader (“\”) to “;”. If you have another type of keyboard, then set the map leader to any other key you want.
• Also, if you don’t need to write the “é”, remove this setting.
• Notice that I have made another setting to move the cursor to the placeholder (“<++>”), I prefer to type shift+tab rather than “ctrl+j”, but remove it if you want.
• Since one day I will use Vim to write in japanese and maybe in arabic or persian (who knows) I have set the command “,ja” to write automatically “{\ja }” in LaTeX files. Further informations in the second part of my post about Vim.
• An other thing which might be worth to say is that if you write “…” in a LaTeX file, it will be automatically replaced by “\ldots”. If you don’t use XeLaTeX but LaTeX, you might find useful to uncomment lines like “imap € \EUR.
• lastly, notice that I have change the “” to “,” (more easy to type with french keyboard). So if you want to enter, let say, \textbf{}, then press “,bf” instead of the usual “bf”.
1. “Notice that I have disable arrow keys to force beginners to use hjkl keys.”
ROTFL
We geeks are really strange.

Nice post. Maybe I’ll start using vim for (La)TeX, too. (I’m currently using Emacs for TeX and vim for email, and I guess that knowing how to use _both_ is like speaking two foreign languages instead of one.)

2. Thank you !

Actually I thought it may be a better idea to force beginners to get good habits. For example, I have shown recently to an African friend how to use computers, and especially how to use Firefox. Instead of using the mouse, I’ve shown him from the beginning how to use ctrl+q, ctrl+w, etc. And now, he always use ctrl+w to close a window.

With hjkl, I don’t move my hand as I do to push arrow keys, and for this reason hjkl keys are quicker to push than arrow keys. That’s why I thought using hjkl instead of arrow keys might be a good habit to learn.

But after writing this post, I have modified my .vimrc and enabled arrow keys for insert mode. And by the way, I will divide soon my .vimrc into several files to clarify it.

I also think you should use vim for LaTeX 🙂

• Sotiris
• October 9th, 2010

this is great !! I am learning vim and so far I love it..your stuff makes it super… only got one problem though..i ve installed vim and your settings files in my xbmc live (ubuntu based) installation.. when i ssh into the machine, vim works great (just had to install exuberant tags). When i run vim locally, it displays some text everytime I enter insert mode. Other times, it doesn’t matter what key I press, I just get 22222222222222s .. is there something wrong with the vimrc script, or something like that? any ideas?

• Sotiris
• October 9th, 2010

ok i think i ve found the problem: it’s these lines that show up when i enter interactive mode.
 if exists(‘&t_SI’) let &t_SI = “\]12;lightgoldenrod\x7″ let &t_EI = “\]12;grey80\x7″ endif" 
what is this \x7 ? is it unicode notation?

3. Hello,

Indeed I forgot that I installed exuberant ctags from synaptic. I will download it and add to github.

if exists(‘&t_SI’) let &t_SI = “\]12;lightgoldenrod\x7″ let &t_EI = “\]12;grey80\x7″ endif"
what is this \x7 ? is it unicode notation?

To be honest, I don’t remember :p When I began to use Vim, I searched the web for setup, and copy paste everything I found, and then learned what was the use of each thing.

After this period, I have removed all pointless stuff, but it seems there is still some relics.

Also, when I wrote this post, I didn’t finished all my settings. But I remembered that I read somewhere we should release early something even if it is not finished (maybe it is someone who quoted Linus Torvalds, I don’t know).

So I have just modified my vimrc once again, pushed to github, and soon I will try to make Vim behave like TeXworks (basically, one screen with source on the left, one screen with the output, e.g. a pdf) as an option.

Cheers

Alexandre Krispin

• Sotiris
• October 9th, 2010

thanks for replying! I commented this part out, and everything works great. I also realised I have to change utf8 to latin, since everything latex i have is still in latin+greek..

4. Ok, you are welcome.

Actually I don’t have enough time to finish all my stuff by now. But next time, instead of updating this post I will write a new post to write some tips and notify another way (and, IMHO, better) to write *tex files, with working input with ibus and working formating.

By the way, I am not sure to understand what is your problem with latin and utf8. Do you use Windows ? If this is the case, I may not be capable to help you (but according to some people it seems you may be able to write utf8 files with TeXworks). If you use a Unix operating system like, say Ubuntu, FreeBSD, or any other one, you won’t have any problem to compile your *tex files.

If you are interested by utf8, then try XeLaTeX (the default compiler with my settings), and if you write maths, then take a look here :
http://github.com/alexandre-k/repository_alexandre_krispin/blob/master/configuration_files_for_text_editors/vim_configuration_files/.vim/ftplugin/utf8.vim

You will notice that with this plugin, you can input directly math glyphs like, say ψ, ℝ, and any others, easily, with a simple shortcut (which you can also change easily). You will also be able to compile it without any problem.

Try with this in your preamble, after removing anything related to fontspec and inputenc :
\usepackage{xltxtra}
\usepackage{unicode-math}
\setmainfont{TeX Gyre Pagella}
\setmathfont{STIXGeneral}

For the documentation :
texdoc xltxtra
texdoc unicode-math
texdoc stix

Cheers

Alexandre Krispin

PS : if you answer, I may not be able to answer before some time.