Tag Info

Hot answers tagged

4

As globpath() takes a comma-separated list of directories, you can build the locations like this (I'm doing this in a primitive way with duplication, as you seem to be not very well versed in Vimscript): function! sourceConfig() let path = $HOME . '/dotfiles/vim/config/global' let path .= ',' . $HOME . '/dotfiles/vim/config/plugins' let path .= ',' ...


3

The \& atom does not do what you think it does. It allows to match two regular expression parts at the same position. To have both strings match in the same line, you need to allow for an arbitrary number of charactes before the matches. This is the pattern: /.*red\&.*blue/ For your example: /.*\<hello world\>\&.*\<goodbye world\>/ ...


3

Tab pages contain windows which contain buffers. You can't have a tab page inside a window. Maybe there is a plugin that sort of does what you want but I'd recommend not taking that path and, instead, learn to use buffers, windows and tab pages as they are meant to be used. Vim is vastly smarter and more powerful than whatever you used before switching. ...


3

Following would work with vim. Perhaps easier to wrap into a function. :%s/$/$ :g/= {/.,/};/join! :sort :%s/\$/\r/g In a nutshell 1. Replace the EOL with a special character (I've chosen $) 2. Search for "= {" and join all lines up until first "};" 3. Sort 4. Replace the special EOL character back to a real EOL character.


2

Your code isn't easy to follow, and in general, substitute() should behave like :s, so I can't tell you the exact problem. However, your whole approach depends solely on text substitutions, and that makes it so complex. Since version 7, Vim has (Python-inspired) functions to work on Lists, and this is what I would use here. I show you this step by step: " ...


2

I'd hesitate to automatically fix this, but the following autocmd seems to do the job. autocmd BufRead * if line('$') == 1 && getline(1) =~# '\r' | edit ++ff=mac | w ++ff=unix | endif It detects files that consist of only a single line that contains embedded CR characters, and automatically performs the conversion. I'd probably add a :echomsg to ...


2

I've been confused by this before, too. I did some digging and found this answer on SO [1], which worked for me. Short answer: add the following line to your ~/.screenrc file: altscreen on [1] screen: how to turn on alternate screen?


2

First question: You must remove block from the default value of 'foldopen': set foldopen-=block See :help 'foldopen'. Second question: You can try these mappings nnoremap <expr> } foldclosed(search('^$', 'Wn')) == -1 ? "}" : "}j}" nnoremap <expr> { foldclosed(search('^$', 'Wnb')) == -1 ? "{" : "{k{"


2

From :help jumplist: When the :keepjumps command modifier is used, jumps are not stored in the jumplist. These mappings do what you want: nnoremap } :<C-u>execute "keepjumps norm! " . v:count1 . "}"<CR> nnoremap { :<C-u>execute "keepjumps norm! " . v:count1 . "{"<CR>


2

Syntax script Create a file ~/.vim/syntax/simple.vim with the following contents: " Quit when a syntax file was already loaded. if exists('b:current_syntax') | finish| endif syntax match simpleVar "\k\+" nextgroup=simpleAssignment syntax match simpleAssignment "=" contained nextgroup=simpleValue syntax match simpleValue ".*" contained hi def link ...


2

Assuming your file's extension is *.foo… Create these files and directories if they don't exist: $HOME/.vim/ftdetect/foo.vim $HOME/.vim/syntax/foo.vim Put the following in $HOME/.vim/ftdetect/foo.vim: autocmd BufRead,BufNewFile *.foo set filetype=foo Put the following in $HOME/.vim/syntax/foo.vim: syntax match FooKey /^[^=]\+/ syntax match FooValue ...


2

In your ~/.vimrc, you can check whether the GUI version is running via :if has('gui_running'). Alternatively, configuration that you put into ~/.gvimrc is only sourced (but at the end!) in GVIM. What you name "themes" is usually called colorscheme, and the variant is selected with the eponymous Ex command. In the general case, you can :runtime (or :source) ...


1

You need the DLLs and any corresponding language runtime files (e.g. modules). What you usually do is: Find out which language version your Vim binary has been compiled against (e.g. by observing the Linking: part of the :version output). Download and install a corresponding package of the language. (On Windows:) Ensure that the DLL is accessible to Vim ...


1

The .vimrc file is loaded before plugins are loaded so it is possible that a plugin is overwriting your mapping. You can find out what the mapping was set to and where it was set by issuing the :verbose command. For example (using UltiSnips): :verbose map <tab> s <Tab> * <Esc>:call UltiSnips#ExpandSnippet()<CR> Last set ...


1

You should use this form: set makeprg=cd\ cmt\ &&\ make If you don't want to escape spaces: let &makeprg = "cd cmt && make" --- edit --- The problem with your initial attempt is that the shell in which makeprg is executed is non-interactive and thus supposed to exit after the execution of a command. Sending it two commands in a row ...


1

It's possible to create a simple shell function which works as it is reading from stdin (although in fact it is writing to a temporary file then reading that). Here's the code I'm using: # An emacs 'alias' with the ability to read from stdin function e { # If the argument is - then write stdin to a tempfile and open the # tempfile. if [[ $# -ge ...


1

Or, leave 'ruler' unset, a performance gain, and press CTRL-G when you want to see the current column.


1

If you want to open VIM with the mintty terminal, you could use the following set-up: First create a bash-script with the following: #!/bin/sh FILEPATH=$(cygpath -u "$1"); vim "$FILEPATH" This will convert the windows filepath into a unix-style filepath for cygwin. Place this script (for example) in /bin/native-vim In regedit (regedit.exe) you should go ...


1

I've installed base16 through yadr, and i've also installed cocoa.vim to have better syntax highlighting.. but installing the latter didn't change much and this is what I have: That is because cocoa.vim has not been maintained for years and the syntax file doesn't fit with the latest Vim. I just fixed it in my fork: ...


1

I don't know if they work with the latest Mac OS X but you can try some of the many applescript solutions that have been floating the web for years. This page has many relevant informations, snippets and links. I've had Terminal.app and iTerm.app versions of that idea sitting in my Finder toolbar for years. You'll obviously need to change their code to ...


1

Oh. Guess what: There was a missing '=' export EDITOR=vim Only found it because mc did not start the editor when moving vi to vi-dontuse


1

Turns out I needed bind -v in my ~/.editrc. Now it works!


1

Don't try to automate your workaround for a borked setup, fix the setup; i.e. consistently use a certain line ending 'fileformat' across all platforms, and ensure that this gets properly detected (by including it in 'fileformats') on each system! For Vimscript files, that canonical format would be unix, because that is handled both by Vim on Windows and ...



Only top voted, non community-wiki answers of a minimum length are eligible