FAQ Database Discussion Community

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

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

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

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

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

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

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

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

## OSX tmux configuration session open file in vim automatically

osx,session,vim,configuration-files,tmux
So I have tmux and vim running in iterm2 on OSX. I have a tmux.conf file that sources a session in ~/.tmux/ called 'left'. I have successfully loaded this session with three panes. Two panes in a left column and a single pane on the right. I have also managed...

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

## vimscript syntax not pattern

vim,vim-syntax-highlighting

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

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

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

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

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

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

## Automatically switch back to NerdTree after pressing “o” on file

vim,nerdtree
When I press "o" on any file in NerdTree list, it opens this file in one of currently opened tabs. Sometimes, when I'm not 100% sure what file to open, I have to do this: 1) o (open file) 2) ctrl-ww (switch back to nerdtree) 3) j or k (go...

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

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

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

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

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

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

## Any way to ignore ^M carriage returns in VIM?

git,vim,github
Most files I'm editing in VIM have carriage returns, so I'm often seeing every line with a ^M at the end. One thing I used to do was to replace them with a command like +e ff=dos, but when I commit with git, it thinks I've changed the entire file....

## how to replace NumberInt(1) to 1 with vim?

regex,vim,replace
I want to replace NumberInt(1) to 1 except in the string in my file with some tool: "bz":NumberInt(1), "batch": NumberInt(2), "something": "something else NumberInt(1)" "bz":NumberInt(1), "batch": NumberInt(2), "something": "something else NumberInt(2)" "bz":NumberInt(1), "batch": NumberInt(2), "something": "something else NumberInt(3)" "bz":NumberInt(1), "batch": NumberInt(2), "something": "something else NumberInt(4)" "bz":NumberInt(1), "batch": NumberInt(2), "something": "something...

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

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

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

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

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

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

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

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

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

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

## error when vim macro recording play

vim,macros
I know how to record a macro use vim. eg. record macro a: in normal mode, qa start recording, do some action, q stop recording. If I want to play it, I can use @a. Now I want to play 10 times, [email protected] should be work, But for me, It...

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

## Pylint Error when using metaclass

python,python-3.x,vim,pylint,syntastic
i try to fix all pylint errors and pylint warnings in a project. but i keep getting an error when i set a metaclass (https://www.python.org/dev/peps/pep-3115/). here is my example code: #!/usr/bin/env python3 class MyMeta(type): pass class MyObject(object, metaclass=MyMeta): # pylint error here pass the error just says "invalid syntax". i...

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

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