" NeoVim init.vim " " Differences with good ol' Vim: " " NeoVim has so many of the modern and helpful Vim options on by default. I'll " remove most of the old Vim configurations that now come by default in NeoVim. " " Also NeoVim uses XDG directories by default, keeping a clean directory tree. " " NeoVim also allows for this file to be written in Lua. I'll stick to using " Vim script becuase it has more documentation and is more concise configuring " Vim options. " " Instead of viminfo, NeoVim uses shada files (SHared DAta) (different format). " See shada-file-name. " " For some reason, as of version v0.8.3 of NeoVim, Vim internal codes for shift- " and control- function keys change in NeoVim. changes to , and " changes to . See https://github.com/neovim/neovim/issues/7384 " " Plugins: There are a lot of ways to install "plug-in"s in Vim. My prefered " way is using Vim packages, available since Vim version 8. See packages. " " Tips: " * To show navigate help files: " K " while on an option to see it's documentation " CTRL-] " navigation while on a Vim help file " * To re-indent: " tab->spaces :set tabstop=n :set expandtab :retab " spaces->tab :set noexpandtab :set tabstop={softtabstop} :retab! " * To justify: " To 'justify' comments or block of text (paragraph) use `gq{motion}` or " `gp{motion}`, where {motion} can be `[/`, `]/`, `ip`, `i{`, `a{`. " * To see the last page of previous command: " `g<` " * Buffer stuff: " :ls " shows all buffers " :b N " Go to buffer N (integer) " Settings " ---------------------------------------------------------------------- colorscheme industry " Command line: set cmdheight=1 set wildmenu set wildignore+=*.o,.git,*.class set path+=./**30 " For gf and :find, add all subdirectories relative to " current file (30 max) to the "search space" " Search set ignorecase set smartcase " Screen set nonumber set scrolloff=5 " show a few lines of context set colorcolumn=+1 " show ruler at position tabstop+1 set laststatus=2 " Add buffer number to the default status line with ruler set statusline=%<%f\ %h%m%r%=b%02n\ \ %-14.(%l,%c%V%)\ %P " TODO: move to ftplugin " TODO: create tags automatically (:!ctags -R . after :w if ft=c) " Tag Jumping " Instructions: create tag index (e.g. $ ctags -R .) " place cursor on tag " ^] to jump to definition " g^] if more than 1 definition " ^T to return (or ^O) "set cindent "set cinoptions=:0,g0 " See C-indenting " Indentation: 4 spaces " See also: autoindent, smartindent, cindent, indentexpr set tabstop=4 " Each '\t' takes 8 virtual (screen) columns set shiftwidth=0 " (Auto)indentation. Also affects: >>, i_C-T, i_C-D set expandtab " Expand inserted s with set smartindent " Smart indenting when starting a new line " Formatting: See fo-table set formatoptions+=t " auto-wrap text (when inserting) set formatoptions+=c " auto-wrap comments (when inserting) set formatoptions+=q " Allow formatting of comments with "gq" set formatoptions+=j " Removes comment leader when joining lines set formatoptions+=l " Don't break long lines that are already typed set formatoptions+=r " Insert current leader after in Insert mode set formatoptions+=p " Don't break honorifics like Prof. Smith set formatoptions+=n " Recognize numbered lists set formatoptions+=o " Automatically insert the current comment " leader after `o`. " Wrap: Auto-break lines longer than 80 colums set textwidth=80 set wrap set linebreak " Don't break words " Mouse set mouse=a " Enable mouse for all modes " Buffers set hidden " Allow for hidden modified buffers " Mappings " ---------------------------------------------------------------------- let $VIMFILES = split(&rtp, ",")[0] map :source $VIMFILES/init.vim map :e $VIMFILES/init.vim map :tabp map :tabn map :bNext map :bnext " TODO: move to ftplugin " C/C++ Programming: map :w:!clear && make "map :!./%:r "map :!./a.out map :cnext map :cprev " "Run cTags" map rt :!ctags -R . map :tnext " Motion to go to beggining of function while cursor is inside nmap [f [m[{k0 " pandoc (& website): nnoremap mm :w:Md2Html nmap mM mm:!updatewebsite_zaz " asciidoc: nnoremap ma :w:!asciidoctor % nmap mA ma:!updatewebsite_zaz " Funcionallity of the following depends on terminal emulator. Needs 8-bit " input enabled " for = Alt key combos " From: https://vim.fandom.com/wiki/Get_Alt_key_to_work_in_terminal nmap h nmap j nmap k nmap l " Go Title Case (and clear highlighted matches) " Ref.: https://vim.fandom.com vmap gt :s/\<\(\w\)\(\w*\)\>/\u\1\L\2/g " Autoformat JSON jumbled data " Ref.: https://stackoverflow.com/questions/26214156/how-to-auto-format-json-on-save-in-vim nnoremap gJ :%!python3 -m json.tool " Replaces previous WORD arithmetic expression with result (from Vim " fandom-wiki) inoremap diWi=" " Views and Sessions (Window layout and Line folding) " ---------------------------------------------------------------------- " It is possible to create folds automatically but idk how to do it. " :mkview so save them :loadview to load them (zo open one, zc close one, " zR to open all, zM to close all, zx to restore)) " Views saves folds. Sessions saves all windows configuration and layout " Load Sessions with $ vim -S Session.vim " To automatically save and restore views for *.c *.cpp files: au BufWinLeave *.c mkview au BufWinEnter *.c silent loadview au BufWinLeave *.cpp mkview au BufWinEnter *.cpp silent loadview