Questions tagged [command]

Question about the command functionality that les the user define new Vim commands.

Filter by
Sorted by
Tagged with
0 votes
0 answers
36 views

Listing maps unreadable [closed]

I often forget a mapping and do :nmap etc to look for it. However, a lot of my mappings appear like this: n Ó :call ToggleFiletype()<CR> n ô :read ! c:\cygwin\bin\...
Tom's user avatar
  • 43
1 vote
1 answer
50 views

Is there any way to "capture" the output of `g<`? (i.e. like how :redir works for other cmds)

I have some functions and mappings that echo paragraphs of summary output for me to "take a pulse" on some things I'm working on. I know that if it disappears before I finish perusing, I can ...
CrashNeb's user avatar
  • 203
0 votes
4 answers
83 views

How can I camel-case extant lowercase text?

I use vim for coding. I have a disability where some of my fingers hurt and I have trouble holding down shift and a letter to produce uppercase. The same goes for parentheses. How can I convert ...
Joselin Jocklingson's user avatar
1 vote
1 answer
40 views

Unloaded buffers and the :ls! command

I ran :ls! (having only a vague memory of the command and not really knowing what I was going to see) and saw a short list of files (maybe 5 or 6) with 'u' in the gutter. Apart from one of the files, ...
Tom's user avatar
  • 43
2 votes
2 answers
444 views

Vim and users with partial finger (or hand) presence and accessibility

How does Vim support single handed users or users that do not have all fingers? Such a condition could come in many configurations, and, in each case, lead to sets of optimal preferences (depending on ...
Joselin Jocklingson's user avatar
1 vote
1 answer
33 views

How do I use parameters within a custom command?

I want to define a global search and replace with confirmation command, something like: command Gfr :s/<parameter1>/<parameter2>/gc So I can type: :Gfr foo bar and Vim will find all ...
David Shaw's user avatar
0 votes
1 answer
66 views

How to show the clock and battery usage in lightline?

I have Lightline installed for a more detailed statusline. Unfortunately, any time I do something like this set statusline+=%{strftime(\"%H:%M\")} it seems like Lightline will override it, ...
Patrick O'Brien's user avatar
1 vote
1 answer
50 views

Using the completion function for a command that is passed as an argument to another command

Is it possible to programmatically get a command's definition so that its completion function can be called manually? Alternatively, is it possible to define a command such that the first argument is ...
Pak's user avatar
  • 1,114
0 votes
0 answers
50 views

How to use <Leader> in a normal command today?

The answer to the question with the same title doesn't seem to work for me. Not sure if the behavior has just changed overtime. To reproduce the issue, open Vim via vim -Nu filebelow.vim, where the ...
Enlico's user avatar
  • 2,184
0 votes
1 answer
24 views

How can I add more to this command?

I have been trying to make this command into a function which gets called by command, but I am not having much luck with it. " Clear registers command! WipeReg for i in range(34,122) | silent! ...
paradroid's user avatar
  • 367
2 votes
1 answer
193 views

Is there any difference in mapping commands with <Cmd> or with :?

As per title, is there any difference in mapping commands when using <Cmd> or : ? For example, is there any difference between the two following mappings? nnoremap <leader>c :close<cr&...
Barzi2001's user avatar
  • 506
1 vote
1 answer
103 views

Lowercase user-commands?

After years of torture, my trusty rusty keyboard is finally waning its power—it now seems to believe that I'm jitter-clicking whenever I press q. Before getting a new one, I would like to ask if there ...
Futarimiti's user avatar
2 votes
3 answers
215 views

Open all files listed in current buffer

I have a file/buffer that contains multiple file names with line numbers. Example: Declaration of x fileA.h +3 Usage of x fileB.c +10 I can open a file with the cursor in the given line ...
MaxGyver's user avatar
  • 229
0 votes
0 answers
47 views

How can I get the success status of a <Cmd> command?

I have a binding that I would like to make it attempt to run the command, and if the command fails to fall back to a different command. vim.keymap.set("x", "L", '<cmd>...
Steven Lu's user avatar
  • 2,241
0 votes
1 answer
67 views

Passing arguments to function in remapping

I have the following solution in my .vimrc that allows me to wrap text with certain delimiters that works function! Wrap(action, delim) let l:delims = {'(': ')', '[': ']', '{': '}', '"': '&...
hilbor's user avatar
  • 15
0 votes
1 answer
39 views

Vim custom command to execute 'c""<Esc>P'

I am trying to write a custom command that executes the following: 'c""<Esc>P', namely cut visually selected text, insert ""and paste the cut text into the quotes. I have ...
hilbor's user avatar
  • 15
0 votes
0 answers
116 views

How do I pass multiple optional arguments from custom command to function?

Given a function with two optional arguments fun s:foo(one = v:false, two = v:false) echom '<' . a:one . ',' . a:two . '>' endf and a custom command calling it command! -nargs=* Foo call s:...
Enlico's user avatar
  • 2,184
1 vote
0 answers
17 views

Can I interrupt the loop through a command completion custom list to trigger recomputation of the list?

Here's a minimal example: function s:compl_list(argLead, cmdLine, cursorPos) if a:argLead == 'opts=' return map(['op1', 'op2', 'op3'], {_, v -> a:argLead . v }) endif return ['initial', '...
Enlico's user avatar
  • 2,184
1 vote
1 answer
39 views

A command that transforms a code comment to a title in a square with many comment symbols, also called an ascii frame

How to create a command that transforms this text # Title Into this text ######### # Title # ######### Is there a name for this kind of text? I have a hard time searching for this in search engines. ...
Paul Rougieux's user avatar
0 votes
1 answer
163 views

How to add command with : to config

The command :LongLines comes from the plugin manu-mannattil/vim-longlines. How can I include it in my Neovim config, so it is executed every time the program starts?
Kolya's user avatar
  • 5
1 vote
1 answer
1k views

`E492: Not an editor command` error only when opening file, but not when using :so %

I have the following in my vimrc: call plug#begin() Plug 'https://github.com/vim-scripts/RltvNmbr.vim' call plug#end() set number RltvNmbr When I type :so % while in my vimrc, it will turn on the ...
brianxk's user avatar
  • 21
0 votes
1 answer
71 views

Stop flushing the last command when hitting enter

Suppose I wrote this command: command! -nargs=1 E echo ' -> <args>' and when user feeds an argument, :E abc I intend to see the following effect as they hit Enter: :E abc -> abc Of ...
Futarimiti's user avatar
1 vote
1 answer
171 views

:normal o in visual mode WORKS

In my environment, invoking :normal in visual mode does visual mode command. " A map for calling command without quitting visual mode " It gets the cursor to the other side of selection ...
Dugesia7's user avatar
-1 votes
1 answer
31 views

How to write the command statement to call customized function briefly?

I have written the function im .vimrc: function! Rep(raw,dest) range python3 << EOF #omit all the codes EOF endfunction In ex mode, i can use it with 1,10call Rep("raw","dest&...
newview's user avatar
  • 291
1 vote
4 answers
56 views

Programatically enter Command line window

I have bind q to :qa that hides q:. Is there a command to enter the Command Line Window that is not q:? How to access the Command Line Window without typing: q:?
Dominik Teiml's user avatar
1 vote
1 answer
105 views

Neovim E276 - Command works in Vim but Not in Neovim

Question Thanks to the comment from @martin-tournoij on one of my other questions. He gave me this piece of code: :%s/0x[a-fA-F0-9]\+/\=submatch(0)->str2nr(16)/ which looks for every hex-number ...
Bog's user avatar
  • 457
1 vote
2 answers
416 views

Insert Result of an Internal Vim Command into Text/Buffer (e.g. vims echo command)

Question I want to have basically the same as :read ![external command], but instead the external command I want to read the output from an internal command. Example Shells echo / external command: :...
Bog's user avatar
  • 457
2 votes
1 answer
70 views

How to save buffer from command?

I'm trying to get :W to also save like :w (I often mistype). I tried something like this: command! W execute "norm! w", but that doesn't work. How can I do this?
fbence's user avatar
  • 667
4 votes
2 answers
159 views

Follow group links in :highlight command

In :highlight command, colors of some groups are shown as this: :hi vim9Comment vim9Comment xxx links to Comment I then have to invoke another :hi command, this time with the linked group as the ...
3N4N's user avatar
  • 5,624
1 vote
1 answer
208 views

Sort from current column from visual selection

I am trying to write a :sort wrapper that sorts from current column. command! -bang -range=% -nargs=* Sortc exe '<line1>,<line2>sort<bang> <args> /\%' .. virtcol('.') .. 'v/' ...
balki's user avatar
  • 355
1 vote
2 answers
488 views

What is @q doing?

I accidentally typed @q instead of :q and the file closed. I checked if I have a macro defined by using :reg q. It shows a long string of jibberish. Is it possible to find out exactly what function @q ...
neverdimed's user avatar
1 vote
1 answer
29 views

How can I make a command that checks iteratively through parent roots until it finds something or reaches C:/?

I made a command line tool to generate static websites. I want a way to use this command line tool from the vim command line, something like the G command from the Fugitive plugin. The tool can only ...
Katie And's user avatar
1 vote
1 answer
127 views

Automate find and replace

When having selected something in visual mode where I want to perform a find-and-replace I always have to run :'<,'>s/foo/bar/g manually. Is there some way so that I can bind it to some key ...
Richard's user avatar
  • 155
0 votes
0 answers
94 views

How do I do a keybind involving <C-ñ>?

I use a keyboard layout designed for Spanish speakers and I've remapped hjkl to jklñ because those are the main home row keys. With hjkl I have to be constantly moving my hand to the left in order to ...
Katie And's user avatar
0 votes
1 answer
36 views

How do I type an insert mode command?

I've recently read that some people put inoremap jk <Esc> on their vimrc to exit insert mode without having to move their hands away from the home row. But then how do you type the letters jk? ...
Katie And's user avatar
2 votes
1 answer
273 views

Keep specific parts of a :s command in nvim

What I'm trying to do is convert between Textile and Markdown links, so it should be able to do something like :s/".*"(.*)/[.*](.*)/, which is to say, keep the stuff that is matched by the .*...
Katie And's user avatar
3 votes
1 answer
536 views

How can I echo a message with newlines so it is displayed with line breaks and is available under :messages

Consider the following: function! RunWithErrorHandling(command) abort let view = winsaveview() let errorOutputFile = tempname() let shellredir_save = &shellredir let &shellredir = '&...
Sebastian Blask's user avatar
2 votes
1 answer
271 views

`:g` to move matching lines to the end of the current selection?

I use vim for my todo list: * [ ] A * [ ] B * [X] C * [ ] D * [ ] E * [X] F * [X] G * [ ] H In order to get the completed tasks out of the way, I can use :g/\[X\]/m$, which ...
Eric Duminil's user avatar
1 vote
1 answer
106 views

How to bind function calls in vim

Suppose I have some extension that allows for calling some function foo(). Can I somehow bind the command :call foo() to just :k for example?
Richard's user avatar
  • 155
1 vote
1 answer
241 views

Is there a way to bind `:qw` to `:wq`?

I often mistype :wq as :qw. I can't create a command for qw though since it doesn't start with an uppercase character. Is there a way I can bind qw to wq?
ChocolateOverflow's user avatar
0 votes
1 answer
1k views

"E16: Invalid range" when run command vim in terminal

I run vim -c 'vnew' and expected it run but it raised the error E16. What I want is auto run :PlugInstall when open vim but not using VimEnter. So I opened vim with -c flag but it didn't run.
Pham Hung's user avatar
  • 113
1 vote
2 answers
698 views

Append inside brackets, quotes, double quotes

Been using Vim for a few weeks now and I find myself constantly using ci" or ci( to change whats enclosed in "" or (). I do also find myself wanting to append inside of the brackets e....
Albert's user avatar
  • 143
5 votes
1 answer
4k views

How do I quit vi/Vim/NeoVim?

I opened vi myfile.txt (or vim myfile.txt, or nvim myfile.txt) to use vi/Vim/NeoVim to edit a file. Now that it is open, how do I quit? If I open vim with no file, the intro screen says :type :q<...
1 vote
1 answer
32 views

Apply next non-blankline function as one part of multi-part user-command

Why do I seem to get different results when I apply this function from the vim command line than when I apply it as part of a user-command? " advance to next non-blank line only if current line ...
markling's user avatar
  • 319
1 vote
1 answer
212 views

Advance to next non-blank line only if current line is not blank

I want to tell a command or mapping to advance to the next non-blank line before executing - but to do this only if the current line is not blank. Ultimately, I intend to apply this to a command to ...
markling's user avatar
  • 319
0 votes
1 answer
76 views

How do I send the output of an :r! command to another Vim command?

I would like to edit some text before dumping it into the Vim buffer. I retrieve the content of a webpage with :r! w3m -dump someurl.com. I would like to delete everything in the returned text from ...
Julius H.'s user avatar
1 vote
2 answers
339 views

How to get timezone using strftime command?

I have a custom command for stamping time in my log files. However, I would like that format to match the one of bash command date. For example, I use this command: :command InLog pu=strftime(\"\...
Vladimir's user avatar
0 votes
1 answer
147 views

How can I create a command alias for :Ex /path/to/directory

I'm trying to make my life easier by making a shortcut for the following command :Ex /path/to/directory I need to to be able to press :akeyword and execute the command above. The directory needs to ...
zen3gr's user avatar
  • 3
0 votes
1 answer
169 views

set a default value to a command that acccepts two arguments?

I often need to delineate "sections" of source code files using a comment character to create horizontal lines. For example if I wanted to draw such a line in a python file I could do :Hline ...
First User's user avatar
0 votes
1 answer
210 views

Is it possible to keep editing the same line when I execute code with !%?

Let's say I have a file with the following bash code: echo "line 1" echo "line 2" echo "line 3" echo "line 4" echo "line 5" echo "line 6" ...
raylight's user avatar
  • 525