All Questions

Filter by
Sorted by
Tagged with
3
votes
0answers
146 views

How do I add autocompletion for variable names for a new language? [duplicate]

I'm writing code in a language called choicescript, and it defines global variables like so: *create <variable name> <initial value> Global variables are defined only in a single file ...
1
vote
1answer
135 views

Vimdiff does not read modeline

I have a modeline in a file # vim: set filetype=sshconfig : This sets filetype correctly in vim, but when opening the file in vimdiff, the filetype is set to conf. How can I tell vimdiff to read the ...
3
votes
2answers
126 views

How to select with the same movement but on a different line

If I have the folowing file: XX:YY:ZZ foobar: some text XX:YY:ZZ foobar: some other text a text breaking the pattern XX:YY:ZZ foobar: some more text And I want to operate on the differents parts XX:...
9
votes
2answers
1k views

How do I prevent Vim from unindenting empty lines?

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: ...
5
votes
1answer
294 views

How can I advance a page without losing my column position?

I like using Ctrl-f and Ctrl-b to "page-up" and "page-down", but I was wondering if there was a way to do that without losing my current position in a row? For example, I like to work with tab-...
2
votes
6answers
200 views

Easiest way to delete e.printStackTrace();

I have the following: e.printStackTrace(); with the block cursor over the semicolon, what is the easiest way to delete that and end up with the cursor where the first e is? So dd for deleting the ...
8
votes
1answer
254 views

Autocomplete for make

If I set a custom make program, is there any way to provide a list of tab completion options that would get activated when I type :make+Space+Tab? With custom commands I can do f.i.: command! -nargs=...
1
vote
2answers
588 views

Execute current file outside of working directory

I know I can execute the current file, lets say a bash file, with :! bash %. But what can I do if I want to execute the current file in a different directory (such as the location of the current file) ...
13
votes
1answer
2k views

Word level diffs in vim

As far as I understand the default vimdiff is doing only linewise diffs. However somtimes is useful to do word level diff, especially for text files like Markdown, LaTeX etc. There are some tools like ...
6
votes
1answer
89 views

save unfolded data to separate file

Within vim you can fold away some data that doesn't pertain to what you're looking for at that moment. So I'd like to save that unfolded data to a separate file and look at it closer, but I don't know ...
8
votes
1answer
153 views

How to get and use the number of each matched line in a global command

In his (very good) book "Pratical Vim" Drew Neil shows how to collect all the lines containing the word "TODO" into a register to use them latter. To do so he simply use a global command: :g/TODO/...
9
votes
1answer
172 views

How can I prevent (or at least prompt to confirm) absurdly large numbers from being used to prefix commands?

It doesn't happen as often as you'd think, but it happens occasionally, and I don't even own a cat. Basically if you mash the number row or numpad and then happen to hit a keycombo that triggers a ...
14
votes
3answers
10k views

How do I tell if Vi or Vim is installed on my Linux distribution?

I use Kubuntu 14.04 with its default installation (bash, Konsole). I want to learn a powerful, all-keyboard, text editor, and settled on one of these: Vi, Vim, Emacs, (and I'll learn Nano since it's ...
1
vote
1answer
158 views

making vim autoclose {} tags adds a space

I added a few lines to my .vimrc to autoclose tags like [], "", '', () these all work fine but somehow the autoclosing of {} adds a space in between them and I have no idea how this comes. "auto ...
16
votes
8answers
21k views

Trouble Using Color Scheme in NeoVim

I don't have a full understanding of how my color scheme is interacting with the term setting in vim and this is impeding my ability to get it to display correctly in neovim. In my .vimrc file, ...
4
votes
1answer
444 views

How to use the value of a register in a key mapping?

I want to map a key to the system command `tmux set-buffer $var` where $var is the value of @0 register. How do i insert the @0 value into the map command map <leader>t :!tmux set-buffer @...
3
votes
1answer
58 views

Match by syntax highlighting instead of expressions

I want to delete all the comments from a program. Vim already knows (in some sense) where all the comments are because it is correctly formatting them based on the syntax file the particular language ...
20
votes
4answers
2k views

Clear a line faster than [0][d][$]

Is there a faster way to erase the text on a line than pressing 0 to jump to the start, then pressing d$ to delete until the end of the line? Also, what if I wanted to delete everything except the ...
19
votes
5answers
8k views

Settings and plugins when root (`sudo vim`)?

It's really frustrating when I need to edit a file as root and use sudo vim somefile.conf and I can't use any of my keybindings and settings and plugins. Is there a way to get all my customizations ...
6
votes
2answers
272 views

imap beginning with <C-o> interferes with omnicomplete

I added the following key mappings: inoremap <silent> <Up> <C-o>gk inoremap <silent> <Down> <C-o>gj The goal was that j/k would still work the way that I was ...
21
votes
1answer
6k views

Can I search for a Unicode combining character in Vim?

I have a file with the character ã (lowercase a + combining tilde). Encoding and fileencoding are both utf-8. ga shows <a> 97, hex 61, octal 141 <~> 771, Hex 0303, Octal 1403 (but ...
10
votes
1answer
3k views

delete lines that match a pattern from a given line to the end of the file

If I have a file with a lot of comments in it and I want to delete all of the comments from say, line 3 to the end of the file, what's the best way to do it? I'm stuck, since what I first tried doesn'...
2
votes
1answer
932 views

Navigate to first diff in diff mode on startup?

Vim diff opens 2 files for diffing, but it doesn't navigate to the first diff section automatically on startup. Can I add something to startup script (like _vimrc) to do this?
5
votes
1answer
160 views

MacVim thinks I have unmatching parentheses, until I place cursor over each parenthesis

I am trying out MacVim for the first time and Vim seems to think I have a surplus of closing parentheses: However, Vim seems to change it's mind. Each highlighted closing parenthesis is no longer ...
4
votes
1answer
507 views

Highlighting Date in Vim

I have a file that has dates in this format: Fri Jun 05, 2015. It's essentially a diary. I have created the syntax keywords Day, Month, dateNum, and Year for the various components of the date but I ...
7
votes
3answers
345 views

Make % jump between identical delimiters

I use Vim to edit LaTeX files frequently. I want to use % to jump between matching $ which can be used to delimit where mathematical expressions are written. I have tried using matchit and, ...
5
votes
1answer
618 views

Highlight double space in markdown

When writing markdown, a double space at the end of a line indicates a line break. Currently, neither single trailing whitespaces nor double-whitespaces are being highlighted. Is it possible to have ...
6
votes
1answer
3k views

Copying a String to a Variable or a Register from Within a Function

I want to write a function which copies, say, the last word of the next line which contains keyword into a variable say var or any named register say l. I did something inelegant: function! ...
3
votes
3answers
189 views

yanking a certain amount of bytes

I'm working on large files for wikisource, along with another guy. I generate a big text file (a few Mb) witch I format a bit using scripts, then I upload the text to a temporary page, where the other ...
2
votes
2answers
154 views

Understanding Vimscripts Through an Easy Example

I want to write a function which takes two strings this and that as its arguments and replaces all instances of this with that. So the function should look like: function! ReplaceThisWithThat(this, ...
2
votes
1answer
762 views

Searching For a String Stored in a Register From Within a Function

If I have something stored in the named register n, then from the normal mode hitting /<C-R>n would search for what is stored inside the register. But suppose I want to write a function which ...
3
votes
1answer
351 views

To Return a True Value if Pattern Match is Found Else Return a False Value

Suppose I am searching for pattern in my text file using vim. Is there a way to store 0 in a variable foo if no matches to pattern are found and store 1 if at least 1 match is found? Thanks.
2
votes
1answer
169 views

How to show the path to the current opened file?

If I open a file in vi like: vi /etc/httpd/conf/httpd.conf Then vi shows in the bottom left corner of the window: "/etc/httpd/conf/httpd.conf" 1009L, 34418C But when I edit the file with a or i ...
4
votes
4answers
226 views

Randomly select a documentation article

I wanted to know if there is some way of fetching a random "article" (maybe article is not the proper term here) from the vim documentation. I found nearly nothing on the subject on vim documentation ...
8
votes
1answer
1k views

Current line number aligned to the left with number and relativenumber

I use relative line numbers along with an absolute line number for the current line: set number set relativenumber The absolute current line number is always aligned to the left, and the help pages (...
3
votes
3answers
2k views

How do I trigger an autocommand when user enters/leaves command mode

I'm using a really clever plugin that changes the line number style (relative/normal) contextually. Basically when you enter insert mode you have normal line numbers and when you leave insert mode it ...
18
votes
3answers
7k views

How to fold comments?

The syntax foldmethod is great, but sometimes I just want to fold the comments in a source file. Also syntax folding of comments only works for C-Style comments like: /* ... */ But not for ...
3
votes
1answer
1k views

Get the offset/position of the current window in the layout

There may be any number of nested vertical and horizontal splits on a Vim screen. I'd like to find the (x, y) coords, in terms of columns and lines inside Vim, of the top-left corner of the current ...
9
votes
1answer
4k views

Argument completion for python

Is there a way to get argument completion for python? I am currently using a combination of ctags, python-mode and YouCompleteMe, but I am missing a function to autocomplete the arguments of a ...
1
vote
2answers
148 views

Persist autocmd per file (not per filetype) without vimrc

I have some autocmd triggering on TextChanged, that I want to have persisted between Vim restarts. I could make a big if-elseif construct in the vimrc, sure, but I prefer saving the autocmd only for ...
10
votes
4answers
669 views

Bring up the current file name for edition in the command line

How can I bring up the path to the current file in the command line, so as to type a similar file name? I don't want an abbreviation that would be replaced by the current file name, I want to edit the ...
2
votes
0answers
798 views

How to set vim theme in Vagrant?

I installed Vagrant within Windows, box is ubuntu server 14.04. My vim script: set t_Co=256 colorscheme solarized " colorscheme molokai But it doesn't works, and I got no solutions with Google. ...
5
votes
2answers
667 views

How to write a file automatically after every change?

Something that helps in text editing and proofreading is that for Insert mode, I have set an IMAP: :imap zz ^[:w^M and when I type zz I return to command mode and also write the current buffer. This ...
10
votes
1answer
2k views

NERDTree How to open a file and automatically close the explorer buffer

When using NERDTree plugin the default behavior is to open a new file and keeping the NERDTree buffer open. What I want to do is to keep this default behavior but also overriding it when I want so the ...
3
votes
1answer
173 views

What is the best way to embed external python modules to vim plugin?

I decided to write a plugin for vim. I want to write it mainly in python, as I am most proficient in it. I started development with this example: http://brainacle.com/how-to-write-vim-plugins-with-...
5
votes
1answer
945 views

Disable swap file for large files [duplicate]

I normally like to keep swap files on, but if I am editing huge log files I usually don't want them. Since I am just viewing the files in vim, it is unnecessary to have a swap file. I could just run ...
9
votes
1answer
5k views

vimL sleep within a function

I'm trying to define a function that will make it easier to see where the cursor is location by putting cross-hairs around it for 100ms. Here's my attempt: function! Flash() set cursorline ...
7
votes
2answers
430 views

Populate ex command line

I'm trying to write a simple mapping that will pre-populate the vim ex command line but leave the user there to execute the command on their own. The use-case is for the user to type <leader>/...
1
vote
2answers
314 views

Force (visual-only) wrap at specific column regardless window size in gVim

This is more gVim (Linux) related since Vim doesn't have a "window" of its own. I'm trying to wrap a text at (say) 80th character, visual wrap only, no changes in file, hence no textwidth or ...
3
votes
2answers
228 views

Call PDF viewer on the compiled tex file

Suppose I am editing a file.tex. How would I open file.pdf in zathura (or any pdf viewer) from vim? I understand how to reference file.tex using '%' but I'm not sure how to reference file.pdf.

15 30 50 per page
1
178 179
180
181 182
196