Skip to main content

Questions tagged [abbreviations]

Vim can handle abbreviations to replace some text by some other text. Question about creating these abbreviations and how to make them work.

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

Is it normal for iabbrev to make vim slower to respond to key presses?

I am using neovim, from inside PowerShell on Windows 10. I am working my way through "Learn Vimscript the Hard Way", and have set up the following iabbrev commands in my ~.vimrc file: ...
centauri's user avatar
0 votes
0 answers
30 views

abbreviation stops expanding with "/"

The following problem with ab is seriously annoying me (seems to have started with vim 9.1): In my .vimrc, I have ab FF ftp://test.com/www. This will usually be expanded with e.g. / when I type the ...
ajo's user avatar
  • 123
1 vote
1 answer
24 views

Insert abbreviation and open completion

I sometimes add abbreviations for local files or projects. For example having: PREFIX_FOO PREFIX_BAR PREFIX_BAZ Instead of typing PREFIX_ I map it to something, for example PP or P1, P2, ... etc. :...
user3342816's user avatar
1 vote
1 answer
140 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
0 votes
1 answer
47 views

Paste from clipboard without triggering iabbr

I have the following in my .vimrc iabbr Alice Bob I have copied the text of Alice in Wonderland from Project Gutenberg using my system clipboard and would like to paste it into a new file in vim. I ...
Joe's user avatar
  • 287
1 vote
1 answer
109 views

A problem with special character in Vim script

I'm trying to build a diacritic plugin which It's just a list of commands like ia <leader>'e é " this one is source just fine ia <leader>ae æ " This one causes error But I'm ...
ekiim's user avatar
  • 133
0 votes
1 answer
46 views

What other than mappings and abbreviations can change the text I'm typing?

The question When editing TeX files (to do so, I use vimtex) if I've discovered that if I write lll in insert mode, I get \ell. How do I find why this is happening? My research I thought "ok, I'...
Enlico's user avatar
  • 2,276
0 votes
1 answer
101 views

vert command works but v doesn't

To open a buffer in a vertical split, you can use the word "vert". For example : :vert term #it opens a terminal in a vertical split :vert sb1 #it opens the buffer 1 in a vertical split ...
floupinette's user avatar
1 vote
1 answer
90 views

Change " to `` or '' depending on whether it's typed after a space or non-space

The usecase is LaTeX, which I write using VimTeX. To make double quoted words one would write ``words''. However, I'm much more used, from many other contexts (both prose and code), to type " for ...
Enlico's user avatar
  • 2,276
0 votes
1 answer
44 views

How to better define abbreviations by using variables?

I add the following lines in my .vimrc let g:shell = "powershell" cabbrev bter bo terminal g:shell but that won't work (I got a CreateProcess failed error). I have fixed with exe "...
Barzi2001's user avatar
  • 808
0 votes
1 answer
243 views

How to make an abbreviation that expands without pressing space

I am trying to replicate the behavior of beg abbreviation shown on the page https://castel.dev/post/lecture-notes-1/ with vimscript. That means I want to make it so that when I type "beg" in ...
user157's user avatar
  • 11
0 votes
1 answer
83 views

List of Acronyms / Abbreviations for a paper

What is the best way in Vim to handle abbreviations for a paper? For example: When working with Artificial Intelligence (AI) there must be .... and furthermore AI enables you to.... And later in the ...
Diesel's user avatar
  • 103
1 vote
1 answer
81 views

How to prevent inoremap mapping from being "run" inside iabbrev? [duplicate]

I have the following abbreviation: iabbrev .d. [[2021-12-02]] I also have the following remap: inoremap [[ [[]]<Left><Left> The problem is, whenever I type .d. to get the date string, I ...
Amplify's user avatar
  • 151
0 votes
1 answer
41 views

how to delete character which inserted automatically

I have the following mapping in my vimrc inoremap < <><left> but this statement conflicts with iabbrev cout cout<< and in insert mode I get cout<<>> how to delete &...
Chintu sharma's user avatar
0 votes
1 answer
397 views

Make 'cabbrev' work from command-line but not search prompt?

I am using NeoVim, and I automatically define an abbreviation for the string W every time the commandline mode starts. However, it seems that commandline mode includes the search modes as well. I do ...
Benben's user avatar
  • 121
2 votes
1 answer
155 views

Inserting abbreviation from file

First, I apologize if this is a trivial question. I have the following file (main.ab) defining a Python snippet: def main(args): ... if __name__ == '__main__': args = ... main(args) And ...
Alexandru Dinu's user avatar
0 votes
1 answer
178 views

How to create an abbreviation that matches a regular expression

I'd like to create an abbreviation that will change the following (in a markdown file): - list item 1 into this: - list item 1 Whenever I type - f it should be expanded to - f (from 1 space to 3 ...
john's user avatar
  • 183
0 votes
1 answer
171 views

Cannot set `:p` as abbreviation of `:pu`

I am trying to set up an abbreviation for :pu as :p, so it is more consistent with :y and :d. cnoreabbrev p pu However this doesn;t work. It will just return cnoreabbrev p pu on the command message ...
John Winston's user avatar
3 votes
1 answer
606 views

iabbrev with <CR> and <Space>

I use vim to develop with Python and it works fine. However I want to improve the behavior for documenting my code. For instance I wrote this in vimrc : :iabbrev """ """ &...
Nimu Nobdy's user avatar
0 votes
1 answer
220 views

How to change cursor position when using iabbrev

When using iabbrev to abbreviate System.out.println (); as sysout, I want the cursor to be inside the parenthesis, not at the end of the sentence. Anyway to do this? Also, would it work for multi-line ...
Kavin Sood's user avatar
0 votes
1 answer
57 views

Change text without interrupting abbreviations

I'd like to add a semicolon automatically in my current line. So I have this in my init.vim: function Test() if matchstr(getline(line('.')), ';') != ';' && strlen(getline(line('.'))) > ...
TornaxO7's user avatar
  • 601
4 votes
0 answers
79 views

Can using too many abbreviations slow down vim?

Recently I started using the iabbr to the best of my abilities. While editing a file I may have sourced as many as 500 abbreviations. I have also noticed that my vim is slowing down recently. The ...
caffeinemachine's user avatar
2 votes
2 answers
702 views

How to create an abbreviation with space

I'm trying to create an abbreviation with the command ab: if I type if ( under INSERT mode, I want some piece of code to be printed immediately. Here is what I've tried: ab if<Space>( if<...
Yves's user avatar
  • 1,023
2 votes
1 answer
62 views

Why does iabbrev end at second character, even after using 0 at the end of command chain?

This behaviour seems a bit strange (^ is the cursor): inoreabbrev @@t <esc>0 what@@t what ^ But: inoreabbrev @@t <esc>0h what@@t what ^ Why using 0 is not enough to put the cursor ...
Karolis Koncevičius's user avatar
4 votes
2 answers
332 views

Abbreviations for local filtype buffers only

After typing tds I would like to see it replaced with the current time stamp in Markdown files, but eg. NOT while editing C source code. The following mostly works (stripped for brevity) except that ...
JohnDoe's user avatar
  • 373
0 votes
2 answers
214 views

vi/nvi (FreeBSD) How to make an abbreviation to a shell command?

I know how to make an abbreviation to a command in vim. For example to print the date, I have this in .vimrc: iabbrev mydate <C-R>=strftime("%a %d/%m/%Y") Now I'm running a VM with FreeBSD as ...
Ottavio Caruso's user avatar
3 votes
2 answers
198 views

abbrev for multiwords

How to add abbrevs made of more than one word? I've been trying: iabbrev a aquilo àquilo iabbrev a aquele àquele iabbrev a aquela àquela What I want to do is have the two words "a aquilo" expand to ...
Paulo Phagula's user avatar
1 vote
1 answer
138 views

Abbreviations: Count backslash as part of the word

I am usually writing LaTeX documents. I like to use :iab iso isomorphism so that if I write a sentence like This map is an iso., it will expand to This map is an isomorphism.. However, I also quite ...
user avatar
0 votes
1 answer
106 views

How can I get vim to type continuously, rather than holding in place for keymappings?

For the purpose of this question, imagine that I have set iab phil philosopher In vim, as far as I know, the default display pattern when typing out the characters "phil" at the start of the word is ...
The Pompitous of Love's user avatar
0 votes
1 answer
118 views

Prevent abbreviations from echoing on the command line

If I want to map a key to a certain command and I don't want the command to echo in the command line, I can do the following: :nnoremap <silent> <leader>N <... command ...> But can ...
SalmonKiller's user avatar
0 votes
1 answer
257 views

iabbrev starting with semicolon

I want some abbreviations for common things typed in e-mails want to start them with a semicolon. iabbrev ;ph 555123467 But this gives me an error: E474: Invalid argument I can have semicolon ...
Rob Mosher's user avatar
2 votes
1 answer
555 views

Abbreviations add spaces when they shouldn't

I'm trying to create an abbreviations to insert a comment and to insert a TODO comment. I wrote them as following: iab co /*__*/<Left><Left><Left> This one produces the following (...
Salahuddin Ahmed's user avatar
3 votes
1 answer
292 views

autocmd changes only applying to new files

I've been going through learn vim the hard way and am currently adding abbreviations via autocmd. I've added the following to my .vimrc augroup outputs autocmd! autocmd FileType php :...
kalenpw's user avatar
  • 133
4 votes
1 answer
750 views

How to put a new line character in an abbreviation?

I tried the following commands: :abb sm Summary:\n :abb sm Summary:\\n but it didn't work, nothing escaped, I ended up with the long form instead of a break. Is there a way to do that from ex mode? ...
leeand00's user avatar
  • 3,681
2 votes
1 answer
164 views

vim-latex: sometimes abbreviations do not expand in tex buffers [duplicate]

I have installed vim-latex v1.10.0 on Fedora 28, using vim-plug: Plug 'vim-latex/vim-latex' I've defined an insert mode abbreviation: :iab bd text I can trigger bd to expand to "text" only with ...
Romas's user avatar
  • 75
3 votes
1 answer
169 views

Wrong abbreviation expansion

I have these abbreviations in my .vimrc: iab seq sequent iab seqs sequents seqs expands to sequents i seq sequent in a tex file (I have installed vim-latex). In an empty buffer seqs expands ...
Romas's user avatar
  • 75
2 votes
1 answer
215 views

How to make abbrev ignore my custom keybindings?

For example, I've mapped inoremap ( (), and if I do iabbrev if if(then it will expand to if(then) instead of if()then (the inoremap is executed after the iabbrev). Is it possible to make iabbrev ...
tga's user avatar
  • 419
1 vote
0 answers
119 views

Abbreviations do not work when space is conditionally remapped

I want to change the behavior of <Space> when the popup menu is open using this map inoremap <expr> <Space> pumvisible() ? "\<Down>\<Enter>" : "\<Space>" However, ...
Mewer's user avatar
  • 11
3 votes
3 answers
287 views

Substitute an insert-mode input immediately

I would like to type begin! in insert mode and having it immediately replaced by: begin [cursor here] end I considered mappings: :inoremap begin! begin end<Left><Left><Left><...
Maëlan's user avatar
  • 263
8 votes
1 answer
922 views

How to make command-line abbreviations that only trigger at begining of line

I have a custom save function, and bound it to :w by using an abbreviation: cabbrev w call SaveBuffer() This works, but I ran into issues when I wanted to reference window local variables because w: ...
Tumbler41's user avatar
  • 7,796
0 votes
1 answer
66 views

Why won't Ctrl-C complete abbreviations when mapped to Esc?

I'm running vim -u NONE -U NONE, then doing :inoremap <c-c> <c-[> (or :inoremap ^C ^[, which I understand to be equivalent), and set an abbreviation, :abb dyca dynamic_cast. The problem ...
TankorSmash's user avatar
3 votes
2 answers
451 views

Case-insensitive abbreviations

I use abbreviations extensively to make writing in languages other than English easier. For example, I have something like this set up for when I'm writing in Italian: inoreabbrev perche' perché ...
mrzool's user avatar
  • 1,052
0 votes
1 answer
161 views

Creating fillable "mini templates"

I am using somebody else's vim script that has a neat plugin that allows me type in something like sub<tab> and it will generate the following for me: sub ___ { ___ } The blank lines act ...
StevieD's user avatar
  • 1,552
2 votes
1 answer
116 views

One abbreviation for various commands with different prefix?

To take a short cut in writing markdown files I need an abbreviation which can combine these abbreviations, autocmd FileType * iabbrev pythoncode ```python```<left><left><left>&...
Lerner Zhang's user avatar
1 vote
2 answers
482 views

Abbreviation-likes containing spaces

Let's get directly to it. I was working with some python code and realized I had written a bunch of elif blocks as else if after working too much in Javascript. My natural thought was "cool, I can ...
Wolfie's user avatar
  • 677
3 votes
2 answers
165 views

Expand abbreviation when the following non-keyword character is mapped to something else

I've got the following mappings and abbreviations in my .vimrc let mapleader = "," inoremap <leader>( ()<ESC>i iabbrev pirnt print Now abbreviations won't expand if the following ...
ShebangGinTonic's user avatar
1 vote
1 answer
2k views

Remap <ENTER> so it makes new line and insert a datestamp

I'm making a program for taking statistics during sports, where I script the games. I'm would like to make a VIM shortcut/remap, so every time I press that it does exactly what the ENTER-key normally ...
Zeth's user avatar
  • 415
1 vote
1 answer
152 views

How to get abbreviations to work inside nnoremap

I would like to have an abbreviation (xdate in this case) expanded when I use it in nnoremap. Is this possible? Here is what I've tried: iab xdate <c-r>=strftime('%c')<cr> nnoremap <...
equant's user avatar
  • 113
4 votes
2 answers
1k views

Shortcut / abbreviation to insert text block

I'm trying to do something fairly simple. I'm writing latex and I have all these blocks of code, that I'm trying to comment out (and disregard the words in the word count). So I have to write these ...
Zeth's user avatar
  • 415
2 votes
1 answer
172 views

Something like iabbrev that works in the middle of words?

In LaTeX the \ldots command is used to make an ellipsis, so I wanted something like iabbrev ... \ldots that would work in the middle of words, so whatever... would become whatever\ldots. Any ideas?
dbmrq's user avatar
  • 847