FAQ Database Discussion Community

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

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

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

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

## Different color schemes on vim

vim,fortran
In my lab, I can either work directly on my work station or on some server that is made available to us. On both my accounts, I have the same .bashrc and .vimrc files. Now looking at the picture below, you can see that there is some minor difference about...

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

## Vim keeps unindenting

vim,indentation
Vim keeps unindenting the lines I want to keep indented if I don't write anything on them... I'll give an example, where the | is the caret. Caret is indented and I press enter if expression: print("hello world") | Caret is indented on the next line, and now I press...

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

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

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

## vimscript syntax not pattern

vim,vim-syntax-highlighting

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

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

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

## Bash: How to generate lines with sequential numbers?

vim,sed
I need to create a list which will hold fqdn's of about 30 servers. Until now, whenever I needed to create such a list, I would: Open vim Manually insert the first line Yanking the first line and then pasting the line as many times as the amount of servers...

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

linux,osx,vim,zsh
I'm a huge vim lover, but I can't find a way to get vim to follow symlinks when opening files. As an example, all the dotfiles in my home dirs are symlinked to within the .zprezto directory: .vimrc -> ~/.zprezto/runcoms/vimrc .zshrc -> ~/.zprezto/runcoms/zshrc I'm keeping my fork of .zprezto in...

## how to change the regex responsible for vim's “current word” search

vim
Is there any way to modify the "current word" search (asterisk) settings so it includes certain characters in its definition of "word". For example, I have a lot of CSS code where there is a dash character in the class names. So, if I have a class named "blue-text" and...

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

## Using vim to develop instead of Emacs on Windows

vim,emacs
I have used Emacs for a long time, say, 6 or 7 years. And it seems that I got Emacs Pinky somehow. Now I am trying to switch to vim, and it's a very good editor, just like Emacs, except that I wonder how you guys develop with it. Using...

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

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

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

## Substitute both the beginning and end of every occurrence of a string with vim

vim
I have more than a hundred of occurrences of the string ?dep= followed by two numbers. So it goes like ?dep=01, ?dep=02, ?dep=03, etc. I need to change the string but keep the numbers at the same time, so for example ?dep=01 needs to become {{ path('annonce-index', {departement: 01}) }}...

## In Vim, how can I compile a .java file in /src/ and run its class file from /bin/?

java,vim
I'm using Windows, and my _vimrc file has the following lines: autocmd Filetype java set makeprg=javac\ -d\ %:~:h:s?src?bin?\ % set errorformat=%A%f:%l:\ %m,%-Z%p^,%-C%.%# map <F9> :make<Return>:copen<Return> map <F10> :cprevious<Return> map <F11> :cnext<Return> map <F12> :!start cmd /k "java %:~:s?src?bin?:r" I just want to use this for quick editing, and I will...

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

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

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

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

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

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

## keypress into buffer from function

vim,snipmate
I'm working on creating a function that will: Inspect the current file I'm working on Create a new buffer in my test directory based on my file name Edit that file and start my snipmate "test" template So far I have everything working except triggering snipmate. What I'd like to...

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

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

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

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

## NerdTree window size is too large when current directory “.”

vim,nerdtree
Every time I type vim . and select some file, nerdtree is too large. there's a way to fix it? ...

## Prevent single letter deletes to spam clipboard manager

vim,clipboard
With unnamed clipboard option included, single letter deletes spam my clipboard manager Is it possible to fix this so that single letter deletes (with x) are not yanked to clipboard.

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

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

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

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

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

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

## Setting tab width based on file type

vim
I'm trying to learn to use Vim. I like indenting by 4 spaces but use 2 spaces for certain languages, such as Nim and MoonScript. I tried adding this to my .vimrc: autocmd BufNewFile,BufRead,BufEnter *.nim :setlocal tabstop=2 shiftwidth=2 softtabstop=2 Problem? It doesn't do anything! All that happens is that the...

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

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

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

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

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

## Indentation changes in new tab-page of vim

python,vim
I'm using vim 7.4. My python indent settings are the default: setlocal expandtab shiftwidth=4 softtabstop=4 tabstop=8 This line was taken from /usr/share/vim/vim74/ftplugin/python.vim which I didn't edit. When I open vim with the command "vim file1.py" then the tab key produces 4 spaces as expected. But when I open a second...

## How to map a key in command-line mode but not in search mode

vim
I want to map a key in VIM in command-line mode but not in search mode(with a leading /), like below: Map Q to q Map W to w Sometimes I typed the wrong command in VIM, like :Q and :W, and I want to make these wrong commands to...

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

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

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

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

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

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