Around 2023 I switched to Neovim as my main editor. You can still use this as a template, but I likely won't be making many changes or updates.
Check out my Neovim config.
This is my current, juiced up IDE mode with LVM and Copilot.
For minimalistic .vimrc that I usually ssh into the servers, see Minimalistic Vimrc.
More info about what worked and what didn't in this setup: Lesons Learned
This is my personal git directory, under source control ready to be deployed across across all platforms.
Sessions are automatically saved to ~/.vim/session
and you will be asked if
you want to restore from an existing session if you open vim without a file
argument. Session names are created based on the --servername
argument. The
default for gvim is GVIM
. If you want to create a unique session you can do:
:SessionName sessionname
Then launch vim with that session name to restore:
gvim --servername sessioname
Note that sessions preserve environment. If you updated .vimrc
or plugins you
will need to manually source them after launching. If your session just got
weird, you can blow away everything other than the buffer and tab list by doing:
:SessionCleanSave
This is the same as setting:
:set sessionoptions=blank,buffers,curdir,tabpages
Then quit and re-launch to clean environment with the buffer list and arglist intact.
Persistent undo is enabled if you are running 7.3 or above. All the undo files
are saved to ~/.vim/undo
. This directory may get somewhat large if you don't
blow it away every once in a while so watch for that.
These are the custom plugins I use:
- Closetag.vim - use
<c-_>
close HTML tags - Emmet.vim - automated expansion for html and css
- Gundo - browse the undo tree in the sidebar
- NERDcommenter - auto-commenting
- ObviousMode - change color of sidebar depending on mode
- PHPDocumentator - generate PHPDoc comments
- SnipMate - auto-complete code snippets
- Tabular - auto-align code chunks
- TagList - browse the tag list
- Tex-AutoClose - auto close tex environments
- Unite.vim - file/buffer/history browsing
- Vim-Align - auto-align code chunks (like Tabular)
- Vim-AutoClose - auto close parens and brackets
- Vim-Coffee-Script - Coffeescript syntax highlighting and helpers
- Vim-Fugitive - git integration
- Vim-Git - runtime rules for git commit, gitignore and etc..
- Vim-Markdown - syntax highlighting and matching rules for Markdown.
- Vim-Rails - ruby on rails integration and commands
- Vim-SuperTab - super-charge the tab key
- Vim-indent-object - text object for Python indent block
- Vim-liquid - support for Liquid with Jekyll extensions for blogging.
- Vim-matchit - skip to closing HTML tag with
%
- Vim-neatstatus - simple status line with colors
- Vim-ruby-sinatra - syntax and snippets for sinatra framework
- Vim-signature - easy navigation with marks (displays in gutter)
- Vim-surround - bindings to easily surround text with stuff
The <leader>
key is bound to <space>
because space is cool.
+
and-
- increment and decrement number under cursor<C-BS>
- ctrl+backspace deletes last word<C-Del>
- ctrl+Del deletes next word<C-F>
- opens the file under cursor in the 2nd split window if open<C-L>
- fix last typo<C-P>
- generate PHPDoc comments at cursor (defined inftplugin/php.vim
)<C-R>
- paste in contents of the unnamed register<C-Tab>
- toggle between splits<C-_>
- close html tag (closetag.vim) or tex environment (tex-autoclose.vim)<Down>
- search current directory for files with Unite<F10>
- insert current date at cursor<F2>
- toggle Tag List buffer<F3>
- toggle paste mode<F5>
- toggle relative and absolute line numbering<F7>
- toggle Gundo undo browser<Left>
and<Right>
- browse through buffers<S-Tab>
- Auto expand and/or jump when using Emmet plugin<Tab>
- next buffer<Up>
- search/display open buffers with Unite<leader><cr>
- break line at cursor (normal mode)<leader><space>
- clear search highlights (double tap<space>
)<leader>H
and<leader>h
- markdown headings (defined inftplugin/mkd.vim
)<leader>o
- insert a blank line (normal mode) (also works with<leader>O
)<leader>y
and<leader>p
- copy and paste using system clipboard (alsoY
andP
)jj
- bound to<Esc>
m<space>
- delete all marks in the document
:VIMRC
- open .vimrc in current windows:SOURCE
- source .vimrc:DOS
- set file format to dos:UNIX
- set file format to unix:MAC
- set file format to mac:FILEPATH
- display the file path in the status line:CTAGS
- runctags
recursively on project directory:SessionName
- set session name for current session:SessionSaveBuffersOnly
- save only buffers on exit (same asset ssop=buffers,args
):SPCLEAN
- runs cleanup routine on spell-check files:RemoveEm
- remove the^M
symbols from the file
On Linux and Mac:
rm -rf .vim
rm .vimrc
git clone git@github.com:maciakl/.vim.git
ln -s .vim/.vimrc .vimrc
cd .vim
git submodule init
git submodule update
On Windows:
rmdir /s /q vimfiles
del _vimrc
git clone git@github.com:maciakl/.vim.git
mklink /d vimfiles .vim
mklink /h _vimrc .vim\.vimrc
cd .vim
git submodule init
git submodule update
On Windows XP:
rmdir /s /q vimfiles
del _vimrc
git clone git@github.com:maciakl/.vim.git
junction vimfiles .vim
fsutil hardlink create _vimrc .vim\.vimrc
cd .vim
git submodule init
git submodule update
Note that you will need junction.exe from Sysinternals to create the symbolic link for the directory. The fsutil executable should be on your system by default.
Your vim should be compiled with +dialog
and +python
.
You may also need these:
You could probably use unix ctags, but they don't have all the features.
####CTAGS Ain't Hard!
On debians and buntus of all shapes and sizes:
sudo apt-get install exuberant-ctags
On windows download ctags.exe
from the link above and put somewhere in your path.
Mac is a little trickier:
- Use Homebrew to install the package ctags.
Then add this to .basrc
or .profile
:
alias ctags="`brew --prefix`/bin/ctags"
Here are some things that work or did not work:
- Git submodules are the worst way of managing dependencies
- Plugin management has improved a lot since the days of Pathogen
- Somehow
ctags
were always a major pain and most fragile element of the setup - A lot of the extensions here broke, or became obsolete
- Having actual LVM support makes a lot of the plugins irrelevant
- Unite worked, but what I really wanted was Telescope
- Sessions were an interesting idea that I initally really liked and used, but then fell out of love with