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

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

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

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

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

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

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

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

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

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

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

## Vim: Is it possible to have a filtered view of a file?

vim
In a given text file, I would like to work on a "filtered view" (hiding lines with a pattern), but still to be able to edit visible lines : the filtering would only affect the visibility of some lines, and as soon as I would reset the filter, the hidden...

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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