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
1 vote
1 answer
15 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
0 votes
1 answer
42 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
92 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
40 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,194
0 votes
1 answer
65 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
0 votes
1 answer
73 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,194
0 votes
1 answer
34 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
  • 550
0 votes
1 answer
166 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
77 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
79 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
38 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
314 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
147 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
160 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
165 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
494 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
203 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
53 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
  • 561
4 votes
0 answers
78 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
628 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,013
2 votes
1 answer
61 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
316 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
  • 363
0 votes
2 answers
197 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
187 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
133 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
97 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
103 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
241 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
517 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
285 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
693 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,577
2 votes
1 answer
157 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
198 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
117 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
276 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
871 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,746
0 votes
1 answer
65 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
416 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,012
0 votes
1 answer
154 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,492
2 votes
1 answer
115 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
479 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
  • 667
3 votes
2 answers
162 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
  • 405
1 vote
1 answer
148 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
  • 405
2 votes
1 answer
169 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
  • 857
10 votes
3 answers
3k views

How do I manage and remember many abbreviations in my vimrc?

I have over 500 abbreviations(iabbr, abbr) and some mappings in my vimrc file from Java, PHP, C/C++ and Latex. It is not easy to remember right away when I don't use the languages for some time. I'm ...
1234's user avatar
  • 235
1 vote
2 answers
490 views

How do I make abbreviations expand for minimal prefixes?

I want to create abbreviation for a large word, say configuration. Vim command works even if we type part of it. Example, s[ubstitute]. When you type s, su, sub, subs, subst, substi, substit, etc., ...
SibiCoder's user avatar
  • 3,372
4 votes
1 answer
1k views

How to create multi-line abbreviations

I want to create an abbreviation for multiple lines. For example, when I type Doc, it has to print a four line text like ############### # function : # returns : # ############## When I tried to do ...
SibiCoder's user avatar
  • 3,372