vimrc

.vimrc configuration for Python

My current .vimrc configuration is below: set nohlsearch set ai set bg=dark set showmatch highlight SpecialKey ctermfg=DarkGray set listchars=tab:>-,trail:~ set list autocmd BufRead *.py set smartindent cinwords=if,elif,else,for,while,try,except,finally,def,class set tabstop=4 set shiftwidth=4 set expandtab set autoindent set smartinden...

How can I create a folder, if it doesn't exist, from .vimrc?

I don't like how vim clutters up my folders with backup files, so I have the following line in my .vimrc file: set backupdir=~/.vim_backup However, sometimes this folder doesn't exist because of new machines where I am copying my user files over. How can I create this folder automatically, if it doesn't exist, from within .vimrc? Or ...

Mapping of <ctrl-#> characters

I've been trying to map certain sequences to parenthesis/bracket completion without any success. I've been trying the following commands to map certain control sequences but they don't seem to work. Does anyone know what I'm doing wrong here? :imap <ctrl-9> ( )hha :imap <ctrl-(> ( )hha ...

.vimrc action onclose

Hi, is it possible to use something like an "vim-close/exit"-Event to execute some last commands before vim quits? I use this lines in my config, to let vim set my screen-title: if $TERM=='xterm-color' exe "set title titlestring=vim:%t" exe "set title t_ts=\<ESC>k t_fs=\<ESC>\\" endif but when i close vim, the title is s...

vim screen restore

Hi, i use vim in screen for development and if i quit vim, the current screen-content stays there... outside the screen (xterm), exiting vim will restore the previous buffer (like: [ server1 ]~$ cmd some stuff, some stuff [ server1 ]~$ cmd [ server1 ]~$ cmd ) But not inside screen. I tried to use xterm as terminal inside scr...

Limiting a match in vim to certain filetypes?

I have the following in my .vimrc to highlight lines longer than 80 chars: highlight OverLength ctermbg=red ctermfg=white guibg=#592929 match OverLength /\%81v.*/ This works quite well. However, the problem is that I would prefer it if it only worked on certain file types. Basically, any programming language should be highlighted and ...

Auto-open NERDTree in vim

Good day. Does someone know how to force .vimrc to auto-open NERDTree each time vim is invoked? The operation system is *nix. Thanks. ...

Favorite minimalistic .vimrc configuration

There are .vimrc related questions found here and here. This question wants to deal with a minimalistic .vimrc file. If you are on a new machine with no .vimrc file what are some 'must turn on' commands you use before doing any typing? ...

gvim: Is there any way to get an array of strings?

I have in my .vimrc: let g:PROJECT1="/a/b/c" let g:PROJECT2="/d/e/f" I then do a bunch of operations on the above strings: let str=":!/usr/bin/ctags ".g:FLAGS_CPP." -f ".g:TAG_FILE." ".g:PROJECT1 exec(str) let str=":!/usr/bin/ctags ".g:FLAGS_CPP." -f ".g:TAG_FILE." ".g:PROJECT2 exec(str) I want to replace the above code with a for ...

Multiple vim configurations?

All, I work in several groups, each of which has its own tab/indentation/spacing standards in C. I'm wondering if there's a way to have separate selectable vim configurations for each? So when I edit a file, I do something like "set group=1" or perhaps local .vimrc's that live in the working directories. Is there support for anything ...

Vim: Calling a custom function from set statusline in vimrc

I'm trying to implement the vim script from the book Learning vi and vim on page 202. The following function works, but when I try to use statusline to call it I get the following error: $ vim $ Error detected while processing /Users/me/.vimrc: E518: Unknown option: \ %{SetTimeOfDayColors()} Here's the vim script (it's currently in my...

vim settings in erb file

how can i apply vim settings to erb file?? like /* tabstop=4 shiftwidth=4 foldmethod=indent */ seems like <% # xxx %> # xxxx <!-- xxx --> didn't work ...

What should go in my ~/.vimrc file? (tab-related question)

I would like tabs in my source code to remain tabs (8 spaces wide), NOT to be converted to spaces, but displayed as 2 spaces. I recall vim being able to accomplish this. Could anyone help me a little? ...

vi command line equivalent to CTRL-] ?

Hi all ! I'm trying to map my own shortcuts in vi. I want to be able to open a splitted window containing the declaration of the function I'm calling the shortcut on. something like this in my vimrc: nmap <unique> <silent> <Leader>tg :exe 'vsplit'\| equivalent of <C-]> but what's the equivalent of C-] in command mode ? ...

Adding a command to Vim

I finally decided to try out Vim, as I am getting increasingly frustrated by GUI editors. So far, I'm loving it, but I can't find any help for a issue I'm having... I am trying to map the command :Pyrun to :!python % in Vim using cmap. The mapping shows up fine if I type :cmap. However, on typing :Pyrun, I get this error message: No...

VIM Python Indentation not working?

So I have VIM7 (enhanced) on CentOS5 and it comes with all the usual VIM plugins/scripts ready to go. $ find /usr/share/vim/vim70/ -name \*python\* /usr/share/vim/vim70/syntax/python.vim /usr/share/vim/vim70/ftplugin/python.vim /usr/share/vim/vim70/indent/python.vim /usr/share/vim/vim70/autoload/pythoncomplete.vim I would think that w...

Load different colorscheme when using vimdiff

How do i load a different colorscheme when i do a vimdiff. I want this because the my current colorscheme does not show some diffs properly in vimdiff like the same fg/bg color for the text. This makes it impossible to understand the diff. So everytime i do a vimdiff i have to do :colorscheme some_other_scheme Can this be done in .vim...

How do I run the file through a shell command in vim for a certain filtype

I now have a solution to this question, which leads me to the next question: how do I run "xmllint --noent" to all .xml files when opening them in vim. I have an example to do --decrypt on load and --encrypt on save for .gpg in my .vimrc, but it is so complicated that I cannot really figure the relevant parts. My latest attempt is: aut...

Automatically quit vim if NERDTree is last and only buffer.

I have the following in my .vimrc: """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Open NERDTree by default """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" autocmd VimEnter * NERDTree autocmd VimEnter * wincmd p So, % vim file.txt opens NERDTree and focuses the cursor in the file.txt buffer. I m...

vim:confirm before closing multiple tabs

I often unintentionaly quit vim using :qa while open many files in different tabs. I wonder if there is any way to have something like a confirmation line showing before closing multiple tabs and quit. Thanks! ...