FAQ Database Discussion Community

## augment the number of lines on indent

vim
in my .vimrc file, I have set ts=2 and that works - that is, it pushes the text two spaces to the right - when i'm using tab to indent in insert mode. Indenting with >>, however, pushes the text 7 spaces to the right. How can I control how...

## Why does Vim sometimes create .swp files?

vim
Sometimes Vim creates a .swp file when I edit something, but not always. Why is that, and what causes Vim to create .swp files? Is it bad to disable them in .vimrc?

## How to use Ctags to list all the references of a symbol(tag) in vim?

vim,ctags
Can I list all the references of a symbol in vim using Ctags? like the 'Find References' In some GUI IDE. The Ctag tutorial just tell how to locate the definition of a symbol ,not all the usages....

## expand delimited text over multiplie lines

string,vim
I am looking for a power vim tip - to expand specially formatted text over multiple lines. say i have Bill | 12 | Male | Blue | right | Pay 150k i'd like it to expand (after some vim magic) to Name: Bill Age: 12 Gender: Male Eyes: Blue...

## 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....

## 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...

## 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...

## How can I map keys in Insert mode that contains Carriage Return in it?

vim,text,insert,editor,vi
How can I map ctrl + enter to go to new line from anywhere in the current line in vim ? I just want to do it for insert mode. I tried :set <C-<CR>> <Esc>o but that doesn't seem to work....

## How do you know what VIM help keyword to search?

vim
I was trying to google how to search within a scope in VIM and found this link. Limiting search scope for code in Vim I wouldn't imagine to come up with the keyword "/\%V" to search help in VIM help. So, I'm wondering how most people get help from VIM...

## "+y operator for yanking to clip-board, not working

vim,vi
I use "+y to yank to clip-board so I can paste it somewhere else. It's working fine on one of my computers but not on an other. Both computers are Linux (Ubuntu) machines. The one where it is not working, I am connecting to it through SSH. Does anyone know...

## 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...

## Unknown function: pathogen#infect

vim,nerdtree,pathogen
I just installed MacVim (and did an override of Vim). And I am trying to get Pathogen to work. When I start Vim, I get the following error: Error detected while processing /Users/nir/.vim/autoload/pathogen.vim: line 1: E477: No ! allowed: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> line 2: E488: Trailing characters:...

## Selecting text and saving it with keymap

vim
I've made c# command line program that takes a window handle and a string as parameters. It brings the window with the handle to the foreground, uses SendKeys to send the string that was passed, and brings the window that was previously at the foreground back to the foreground. I...

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 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? ...

## Vim - how to run current python3 file in the python shell?

python,python-3.x,vim
I have a file called myFile.py on my desktop. This is the file: class Node: def __init__(self, data, next): self.data = data self.next = next def __str__(self): self = node while node.next: print(node.data) node = node.next return node.data I normally edit the file in IDLE. In IDLE I can click...

## Vim Statusline: Word search

search,vim,statusline
I've searched hard for this and haven't been able to find what I'm after. On my statusline I want a count of the number of matches that occur in the current file. The vim command below returns what I want. I need the returned number to be displayed in my...

## Enforcing coding styles in Visual Studio and VIM

c++,visual-studio-2010,visual-studio,vim,coding-style
I work with a medium sized team of developers, with half being Linux developers using VIM on Ubuntu and MacVIM on OSX, and the other half being Windows developers using Visual Studio 2010 or later. A fair bit of time has been wasted in the past when handling things like...

## 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...

## Change vim-airline colorscheme via vim-sunset plugin

vim,autocmd
I just recently discovered two VIM plugins that I find very useful, namely vim-sunset (http://vimawesome.com/plugin/sunset) and vim-airline (http://vimawesome.com/plugin/vim-airline-sad-beautiful-tragic). Changing the colorscheme with vim-sunset was easy, but I would like it to also change the colors in my airline. I have tried to achieve this via function! Sunset_daytime_callback() " Version 1...

## How to jump/display the column of an error

python,vim,syntax,pylint,syntastic
To check the syntax of my python scripts I am using the syntastic vim plugin with pylint as checker. Is there a way to not only display or highlight the line where an error occurs but the column/exact position of this error too? I used a vim syntax checker plugin...

## What is difference between Vim's clipboard “unnamed” and “unnamedplus” settings?

vim,clipboard
What is the difference between these 2 settings? set clipboard=unnamed set clipboard=unnamedplus Which one should I use in order to have multi-platform .vimrc?...

## Gtk vim remove mapping of

vim,settings
I used classic vim, but recently i moved to gtk-vim on ubuntu, but emmet plugin don't working, it is because when I press <C-Y> it copies above char to cursor position, i failed to disable it. When i set unmap or iunmap <C-Y> it writes that there is no maping,...

## 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)

## Find entries with zero distance variance and recorded watts

regex,xml,vim,garmin
I'm a cyclist and a programmer. During my rides, I'm recording data to xml files using a phone based gps tracker and a power meter. After the ride, I use the power meter software to merge the data and then upload to a web site. On the website, the resulting...

## Vim: How to search for more than one word in the same search?

search,vim
Is it possible to search within vim for more than one word? For example: Let's say i'm inside vim and I press / in order to start a search for a certain word, is it possible to search for more than one word in the same search?...

## 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...

## How can I “register” a new help.txt document via .vimrc?

bash,vim
I am writing a bash script which installs and configures vim plugins, i.e. it creates a new .vimrc and then echoes the config text into it. #! /bin/bash echo "installing Pathogen plugin manager" mkdir -p ~/.vim/autoload ~/.vim/bundle && \ curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim echo "installing ctrlp" git clone https://github.com/kien/ctrlp.vim.git ~/.vim/bundle/ctrlp.vim...

## 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>" ...

## Why does Vim make certain object keys yellow by default?

javascript,node.js,vim,sails.js
I use Vim as my terminal editor and one of the things I noticed was that it marks certain words such as 'status' yellow by default. Here's a screenshot: I'm little confused because I'm not sure whether it's suggesting that I don't use that word in my model object?...

## How can I 'change in number' or 'change in digits' in Vim

vim,numbers,editor
I'm regularly editing CSS in Vim and need to change a value like: width: 300px; to something else like: width: 178px; Normally what I do is navigate to the 3 in 300 and type cw to change the word. But if I do this I have to type the px...

## bash script “ignores” .vimrc

bash,vim,autocmd
I have a problem as follows: I have a script which copies a log file from remote machine, does some modification on it and then opens it in vim, problem is vim doesn't auto recognize the file type (which outside of the script id does) – I need this for...

## Vim search using regular expression

regex,vim
I want to search a string which starts with "abc" and ends with "xyz" in vim. Below are the commands I've tried: :1,$g/abc[\w\W]*xyz/ :1,$g/abc$\\w\\W$\*xyz/ :1,$g/abc*xyz/ "[\w\W]*" means the texts between "abc" and "xyz" can be any characters "1,$" means the search range is from the 1st line to the last...

## is there any vim plugin to select block of code in any language?

vim
I mean, if my cursor is pointing somewhere inside of javascript else block, is there a plugin for one shortcut to be able to select all lines inside this else block, regardless to on which line exactly I'm currently in this else block pointing my cursor, so that, if I...

## Replace all newlines between “two lines with certain patterns” with a comma in vim

regex,vim,newline
If I have to replace newlines with comma for all lines between Pattern 1 and Pattern 2, how do I do it? From: Pattern 1 abcd edfgads asd adsad ... Pattern 2 to: Pattern 1, abcd, edfgads asd, adsad, ..., Pattern 2 ...

## Install Vim via Homebrew with Python AND Python3 Support

python,python-3.x,vim,homebrew
I would like to enable Python auto-completion in Vim so maybe this is a non-issue. This is what I've observed: First, Virtual Environments provides the ability to assign an interpreter on a per-project basis. The assumption being both Python 2.x AND Python 3.x could potentially be used. I've installed both...

## 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...

## Assigning save (:w) to w in vim

vim
I want to be able to save a file in vim while in the insert mode. I thought of using the following shortcut: inoremap <leader>w <Esc>:w<cr> While the shortcut saves the file in the insert mode, it leaves the cursor one spot ahead of where the cursor would be if...

## 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...

## Disable Wrapping Cursor in Eclipse

eclipse,vim,vi
I'm mostly using Vi (edit: Vim) for text editing and the viPlugin for Eclipse Juno. Eclipse seems to have a very annoying behaviour of "wrapping" the cursor to the next/previous line, if yout reach the end/start of a line through cursor keys. (Reproduce by placing the cursor on the first...

## 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 do I insert the same line into multiple files using VIM

vim
I would like to insert lines across multiple files the same way i can search and replace across multiple files. For example, in order to search and replace the same string across 4 files I would do this (with multiple files open): :115s/fidget/widget/|:wn|:115s/fidget/widget/|:wn|:115s/fidget/widget/|:wn|:115s/fidget/widget/|:wq How would I insert a line instead...

## VIM - Reformatting indentation and braces

vim,coding-style,vim-plugin
When working with blocks of code in VIM, I'm able to easily re-indent blocks of code via selecting a region in visual mode (SHIFT+v), then just hit =. This re-tabs lines of code, uses the correct indentation depths, hard-tabs vs spaces, etc. I have a large set of functions I...

## Using vim-quickrun for “PHP REPL style”

php,vim
I'm trying to get some "repl-like" feature for PHP, inside vim. Basically, what I want is to be able to visually select a part of my script, execute it, and see the result in a separate buffer. But I don't want to execute the whole current file (so :!php %...

## How to highlight rulerformat

vim,highlight,rc
I want highlight the rulerformat in my .vimrc. I have set ruler set rulerformat=%55(%{strftime('%a\ %b\ %e\ %I:%M\ %p')}\ %5l,%-6(%c%V%)\ %P%) I have subsequently tried all of the following: hi rulerformat ctermbg=1 hi rulerformat ctermbg=red hi Group1 ctermbg=red "if you modify the rulerformat slightly you can try to access group 1...

## Delete backwards from cursor to the end of the previous line in Vim?

vim,vi
Say I want to edit the following line: var myVar = "I am a string!"; So that it looks like this: var myVar = "I am a string!"; Is there a movement that goes to the end of the previous line?...

## Custom mappings in help text buffers

vim
I tend not to use windows much in Vim (I prefer tabs), but there are certain things that use them, such as help text buffers. I'm fine with that, but with how seldom I use windows, it usually takes me a second to remember how to close the window (<C-w>c)...

## vim: E14 Invalid Address, reassign variable inside if statement

vim
I'm trying to make my tab spacing dependent on file type. But I get the error E14 Invalid Address on line 3. function! Tabs() let t = 4 if (&filetype ==? 'yaml') || (&filetype ==? 'yml') t = 2 endif " size of a hard tabstop let &tabstop=t " size...

## 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...

## Highlighting Vim text with black background when ANSI colors are off

osx,vim,ansi-colors
I'm on OSX. I've turned ANSI colors off in Terminal.app. This is great, but now visual selections are no longer highlighted. I'd like them to be simply inverted with a black background and white text. I know this is possible in a colorless terminal, because the status line is still...

## Compiling C++ code from vim

c++,linux,vim,terminal
My .vimrc file looks like that: set exrc set secure set number set tabstop=2 set shiftwidth=2 set expandtab set autoindent set background=dark set vb t_vb= set colorcolumn=110 highlight Pmenu ctermfg=2 ctermbg=0 guifg=#ffffff guibg=#0000ff highlight ColorColumn ctermbg=darkgray autocmd CompleteDone * pclose compiler g++ But, when I am opening some C++ files,...

## 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? ...

## how to apply macro on list of lines with vim

linux,vim,macros
let's suppose I want to apply a macro stored on register 1 on lines: 2, 5, 9 but without applying on lines in between. I saw that you can give a range but that is not what I want. I've tried some variation on :2, 5, 9 @1 without success

## VIM Convert Text to URL with Search/Replace

vim
I have a document that contains long filenames, followed by a hyphen, followed by a description of the contents of the file. The files are all PDFs. I am converting this document into a page on our website, so that it has the filename, which should be a link to...

## 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...

## vim comment/uncomment with one mapping [duplicate]

This question already has an answer here: What's a quick way to comment/uncomment lines in Vim? 32 answers I'm new(bie) in vim. I've got the following mapping to comment my python code : nmap cc 0i#<ESC> I would like to have the same mapping to uncomment a line. I...

## unique search and replace

excel,csv,vim
I have a csv with two columns. If I import this csv into excel I end up with column A and column B. Column A contains a string of text eg: 1234 (each row has a unique value) column B contains a string of text eg: abcd1234 I need to...

## Shortcut to finding first match in file

regex,vim
When searching with "/" in vim I find myself often wanting to go the first match of a file. I know that I can simply do: gg/<pattern> but the "gg" adds an entry into my jump list which I may not want. I feel there should be a way within...

## Vim not showing messages for less than 3 occurrences substitutions

vim,macvim
Lets say Text1 has 4 lines 1 2 1 1 After :%s/1/A/g, Vim will give message says 3 substitutions on 3 lines Text2 has 3 lines 1 2 1 :%s/1/A/g There are no messages showing. I typed ":messages" nothing in the history either, so I wonder if there's a way...

## open VIM with default code [duplicate]

vim
This question already has an answer here: How can I automatically add some skeleton code when creating a new file with vim 8 answers Automatic syntax/headers in vim for c++ files 3 answers I don't know if it's correct to ask this question here. I am a programming enthusiastic...

## 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?

## 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...

## 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...