How to get path to the current vimscript being executed

” Relative path of script file: let s:path = expand(‘<sfile>’) ” Absolute path of script file: let s:path = expand(‘<sfile>:p’) ” Absolute path of script file with symbolic links resolved: let s:path = resolve(expand(‘<sfile>:p’)) ” Folder in which script resides: (not safe for symlinks) let s:path = expand(‘<sfile>:p:h’) ” If you’re using a symlink to … Read more

Enabling markdown highlighting in Vim

About the native syntax highlight for markdown I think it only works for files with the extension .markdown by default. I was having problems with markdown syntax highlight for my .md files. I tried: :set syntax=markdown And it worked. So i included the following line in my .vimrc: au BufNewFile,BufFilePre,BufRead *.md set filetype=markdown Now my … Read more

Paste in insert mode?

While in insert mode hit CTRL-R {register} Examples: CTRL-R * will insert in the contents of the clipboard CTRL-R ” (the unnamed register) inserts the last delete or yank. To find this in vim’s help type :h i_ctrl-r

Does Vim load plugins after loading vimrc?

Yes. vimrc is loaded before plugins. If you look at :h initialization you will find that step 3 is load vimrc and step 4 is load plugins. You can also see that vimrc is loaded before plugins by looking at the output of :scriptnames. scriptnames lists all sourced scripts in the order they were sourced … Read more

Cut to the system clipboard from Vim on Ubuntu

Your version of Vim doesn’t support X, which is required for clipboard access. By default, Ubuntu ships several builds of vim and only the GUI variant supports clipboard access. I always recompile vim from source so that a single vim (with symlinks for gvim etc) supports everything required (including :gui to switch from command line … Read more

Tabbing visual selection

You can prefix a number, ie. 2> to indent two tab stops. Or, you can use > to indent once, then . to indent again (this works even though the block is no longer highlighted). If you go too far, u will undo one step at a time. Another useful command is gv to restore … Read more

Multiple file types in vim

You can specify to use multiple filetypes at the same time. For example: :setfiletype html.php But most of filetype plugings and syntax files are not designed for such cases. See also :help ‘filetype’

Pathogen does not load plugins

This seems to be common problem caused by the “system” vimrc in some distributions setting filetype on before you set up pathogen. So turning it off and back on again forces plugins to load correctly: call pathogen#runtime_append_all_bundles() filetype off syntax on filetype plugin indent on More info here.