FAQ Database Discussion Community


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

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

vim comment/uncomment with one mapping [duplicate]

function,vim,mapping,comments
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...

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

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

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

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

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

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

Sending signal to bash shell launched in GVim

bash,vim,signals
How do I send a signal (say, SIGINT), to a shell launched inside GVim, using a keyboard shortcut? Neither Ctrl+C nor Ctrl+D seem to work....

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

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

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

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

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

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

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

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

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

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

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

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

In Vim, how can I undo opening?

vim,undo,nerdtree
I started using NERDTree recently. When I opened a file while having split window, the window of a new file was not I intended. Consequently, I had lost my unsaved buffer by opening a file. Is there any way to undo opening files or reopen my unsaved buffer?...

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

issues with installing newer cabal version for haskell vim now

ubuntu,haskell,vim,ubuntu-14.04,cabal
I would like to install this vim plugin: https://github.com/begriffs/haskell-vim-now When trying to run the suggested installation script: curl -o - https://raw.githubusercontent.com/begriffs/haskell-vim-now/master/install.sh | bash I get: --- Cabal version 1.18 or later is required. Aborting. I then try to install a newer version of cabal: [email protected]:~/Downloads/cabal-install-1.22.6.0$ ./bootstrap.sh The response I get:...

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

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

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

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

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

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?

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

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

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

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

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

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

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

Return to shell output from last run shell command

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

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

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

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

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

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

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

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

vimscript syntax not pattern

vim,vim-syntax-highlighting
I have this vimscript: syn region fdocCommand start="^@" end="$" contained syn region fdocComment start="^@" end="[email protected] " contains=fdocCommand keepend " syn region fdocComment start="^@" end="[email protected]" contains=fdocCommand keepend but what i need is the region defined by: start="^@" followed by anything except "tangle" or "felix" and ended by either "@tangle" or "@felix"....

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

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

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 + netrw: open multiple files/buffers in the same window

python,vim,nerdtree,python-mode,netrw
I have recently switched to VIM using NERDTree and python-mode. As NERDTree seems to have a conflict with python-mode and breaks my layout if I close one out of multiple buffers, I decided to switch to netrw since it is shipped with VIM anyway. But having a file opened, if...

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

Make vim follow symlinks when opening files from command line

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

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