FAQ Database Discussion Community

## Right way to set up Rust using Vim

vim,rust,rust-cargo
I've finally started to dive into Rust and want to clarify some issues when it comes to setting up everything nicely. I'm using vim on Linux and found a nice plugin for syntax highlighting. Autocompletion is somewhat troublesome though, using phildawes/racer. The plugin needs the src location for Rust which...

## How to exit insert mode using autocommand upon losing focus?

vim
Currently, I am using the following command as suggested by Auto save files when focus is lost. autocmd FocusLost * wall! However, I cannot apply <ESC> trailing the wall!. Vim will complain about it and I partially enter normal mode. (The message-box actually takes the focus of cursor.) Any suggestion...

## The “-” key goes up a line in vim

vim
When I hit the "-" key on my keyboard vim goes up a line. My .vimrc is blank and when I type in :map - vim says "no mappings found." I have no idea what could be causing this. I am using a Mac—could it be a Terminal.app problem? Thanks...

## Dynamic pattern for vim highlight

vim
In the vim help, there is a suggestion to use highlight groups for highlighting text greater than the textwidth: Another example, which highlights all characters in virtual column 72 and more: :highlight rightMargin term=bold ctermfg=blue guifg=blue :match rightMargin /.\%>72v/ I would like this to always reflect the value of texwidth...

## Replacing a string with empty line

vim,sed,vi
I have a file which has 2000 lines of data (file name is data.tsv). I want to replace the string with empty line where there is a matching pattern, in my case is PMC: How can I do with Vim or other sed command? Thanks, Rio ...

## How to search and replace from the last match of a until b?

regex,vim,latex
I have a latex file in which I want to get rid of the last \\ before a \end{quoting}. The section of the file I'm working on looks similar to this: \myverse{some text \\ some more text \\}% % \myverse{again some text \\ this is my last line \\}% \footnote{possibly...

## Moved .vimrc in a new dir, trying to get it to work

vim,macvim,vim-plugin
Disclaimer: I'm new to vim/tmux. I'm on a Mac using MacVim I was told to use version control on my dotfiles. Before my dot files were all placed in my root ~ like so: ~/ .vimrc .tmux.conf .vim /bundle /autoload .viminfo etc But then I figured it would be a...

## Temporarily declare a word as wrong in vim spellchecker

vim,spell-checking
I'm writing a document with vim and latex. I recently noticed a word that I use ("tree"), but which is incorrect in the context of my document. I corrected it on the whole document. However, I have the habit to use this word instead of the correct one, when writing....

## How to set a portion of the status line a certain color only if an element is evaluated- Vim

vim
In Vim I'm trying to make my status-line to work how I want it to. Here's what I'm going for: When the file I'm editing has been saved, I want it to look like this when saved: And this when unsaved: The former I see, but I get this when...

## Open file under cursor declared as #include in the C/C++ code in Vim?

file,vim
I now how I can open a file under cursor in Vim. Is there any way to also open files declared like below? #include <iostream> #include "limits.h" ...

## Show tex section list in vim

vim,tex
I like to use vim for tex file editing. My document is lengthy, so I hope to show a list of section or subsection and navigate by just typing enter on the section name. Please let me know some good plug-in or setting. I know taglist plug-in shows a method...

## open a completion popup from normal mode

vim,omnicomplete
Gived this script (packages suggestion was simplified, original takes care of <cword>) function! CompleteImport() let packages = ['java.util.Vector','java.lang.String'] call complete(col('.'),packages) return '' endfunction inoremap <F8> import <C-R>=CompleteImport()<CR> while on insert mode you can add an import and choose between suggested packages pressing F8 But I want to be enable to...

shell,vim
I run my tests file like such: :!bundle exec rspec my_file_spec.rb When I run that command it displays my test results in another window and I get "Press ENTER or type command to continue" to return back to vim. That's all working. What I'd like to do though is get...

## Vim highlighting sometimes requires a kickstart?

vim
Centos 6, vim 7.2.411, my .vimrc file: autocmd BufNewFile,BufRead *.html set filetype=php set tabstop=4 set shiftwidth=4 set nowrap set autoindent set number if has('mouse') set mouse=a endif set backspace=start,indent,eol set t_Co=256 colorscheme molokai (Although I code in php I save my files as .html - a bad practice I imagine?...

## Strange vim registers behavior when used with execute "normal

vim
Why does the following command does not use the content of what is first registered in the unnamed register, if this content is a number ? execute "normal! cc".(@"+1)."\<esc>" ...

## VIM: Use python3 interpreter in python-mode

python,vim,ubuntu-14.04,python-3.4,python-mode
I have recently switched to vim and configured it for Python-programming using this tutorial. Before, I have made sure that vim supports python3 (vim --version shows +python/dyn and +python3/dyn) using this article. But when executing a file from python-mode, still the python2.7 interpreter is chosen. How can I configure vim...

## How can I save in vim a file with the actual fold text? (“+— 43 lines […]”)?

vim
I am looking for a way to save to a new text file a file that is folded, with all the folds closed. In other words, just as I see it on the screen. Is it possible? (I will have to print the code later, and parts of it are...

## How to delete a WORD in vim in insert mode

vim
Is there a way how to delete a whole WORD (e.g. from vim path/to/some/file.txt to vim) in insert mode? To delete a word in insert mode the C-W shortcut works well. I got used to use C-W in bash too but bash actually deletes whole WORDs. Now I'd love to...

## match wordchar and/or dot string of anylength

regex,vim
This matches a word /\w\+ This matches a any number of dots /\.\+ Why doesn't this match any number of words combined by dots? /[\w\.]\+ ? The w seems to be matching actual 'w's instead of a word character, whether I escape it or not....

## Can I define command-line commands for VsVim?

visual-studio,vim,vsvim
Is it possible to define my own custom command-line commands in VsVim like it can be done in Vim and described here? I tried adding different variations of the following lines to my .vsvimrc file, without success. command clean :vsc CodeMaid.CleanupCode<cr> :command clean :vsc CodeMaid.CleanupCode<cr> command clean execute ":vsc CodeMaid.CleanupCode<cr>"...

## Vim says 'missing :endif', but I'm sure its there

vim,vim-plugin
Consider the following vim code. function! s:foo() if s:bar() let a = 1 endif endfunction function! s:bar() python << EOF vim.command('echoerr "blabla"') EOF endfunction command! Foo call s:foo() map <F7> :Foo<CR> Open a vim session and press F7. Vim wil then throw an error saying E171: Missing :endif. How is...

## Make map faster in vim

vim
I want to create these two mappings in my vimrc file: map [ { map ] } but the problem is, there are a lot of mappings that start with [ or ] and their presence makes my maps slow, because right after pressing [ or ] it needs to...

## Vim background color “dark” = “black”? or I didn't install correctly?

vim,macvim
I added a color theme expected to be, in which the background color is lighter than black.: But my my color theme looks complete dark. Whats wrong with it? ...

## How to skip a command in redo

vim
How is it possible to skip a command wile using redo (ctrl-R) ? I made a mistake and put my file in lowercase, I can go back and undo the command, how can I redo all the other commands done after?

## Highlight bash internal varibles using VIM

bash,vim,vim-syntax-highlighting
Is it possible to Highlight bash internal varibles using VIM? For example the variables described on this page would appear a different colour than the user defined variables. http://tldp.org/LDP/abs/html/internalvariables.html ...

## element.queryselector not showing in Vim

javascript,vim
Using various javascript-syntax for Vim, but for some reason element.queryselector() and element.queryselectorAll() don't seem to be visible from my omni-completion. Here are my list of javascript syntax libraries. NeoBundle 'pangloss/vim-javascript' NeoBundle 'isRuslan/vim-es6' NeoBundle 'othree/yajs.vim' NeoBundle 'nikvdp/ejs-syntax' Any ideas? Could there be a conflict between the various syntax libraries? ...

## neovim colors not “just working”

vim,vim-syntax-highlighting,neovim
I have some simple (default) syntax highlighting, and other colors, in my regular vim. I'd like to try out neovim, so I did the cd && ln -s .vimrc .nvimrc && ln -s .vim .nvim I'm currently on ubuntu, and installed neovim from the ppa at: https://launchpad.net/~neovim-ppa (I can paste...

## Measuring time spent in certain types of files in vim

vim,macvim
Is there a way to measure how much time I spend in certain types of files while working in vim? I would like to measure how much time I spend writing application code as opposed to tests (they all have a predefined file name *_spec.rb)

## How does this series of keystrokes in vim delete everything but the numbered lines?

vim
Working through this just the middle kata, Leave only the numbered lines. LINE 1 LINE 2 LINE 3 That's all. Thank you very much. the following keystroke sequence makes sense and does something in the buffer: djGd2kZZ It's basically chaining commands together. But what is the following doing exactly, and...

## Select a different keystroke than colon ':' to enter command-line mode in vi

vim,vi
Is there any way to achieve that remapping? I looked a bit into map and inoremap but they appear to affect within a given mode, not how to enter a given mode....