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
0answers
7 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 ...
4
votes
2answers
120 views

Autocorrecting final sigma

When writing Greek, sigmas at the ends of words should have a different form. Can I do something automatically to replace: μῖσοσ by μῖσος, and so in all such cases?
0
votes
1answer
22 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 ...
0
votes
1answer
32 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 ...
0
votes
1answer
32 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 ...
2
votes
1answer
40 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 """ """ &...
0
votes
1answer
36 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('.'))) > ...
3
votes
0answers
62 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 ...
1
vote
2answers
144 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<...
2
votes
1answer
46 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 ...
3
votes
2answers
208 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 ...
0
votes
2answers
119 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 ...
10
votes
3answers
2k 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 ...
2
votes
2answers
75 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 ...
1
vote
1answer
76 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 ...
0
votes
1answer
55 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 ...
0
votes
1answer
62 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 ...
0
votes
1answer
150 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 ...
3
votes
3answers
146 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><...
2
votes
1answer
335 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 (...
3
votes
1answer
205 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 :...
3
votes
1answer
292 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? ...
3
votes
1answer
149 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 ...
2
votes
1answer
119 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 ...
2
votes
1answer
105 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 ...
1
vote
0answers
72 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, ...
0
votes
1answer
58 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 ...
6
votes
1answer
503 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: ...
3
votes
2answers
305 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é ...
0
votes
1answer
99 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 ...
2
votes
1answer
83 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>&...
1
vote
2answers
422 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 ...
3
votes
2answers
127 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 ...
1
vote
1answer
796 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 ...
1
vote
1answer
117 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 <...
4
votes
2answers
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 ...
2
votes
1answer
143 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?
1
vote
2answers
431 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., ...
4
votes
1answer
839 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 ...
1
vote
0answers
72 views

vim insert abbreviation with text in front of the map

Is there an option to make vim expand an abbreviaiation at the end of a word? In other words let's say I map :iab bb bar, how can I get the expansion: foobb<space> = foobar?
4
votes
1answer
242 views

insert mode Abbreviations work in command mode, but not in insert mode

I have: au BufRead,BufNewFile *.tex set filetype=tex au BufRead,BufNewFile *.tex inoreabbrev ß \ss{} au BufRead,BufNewFile *.tex inoreabbrev ö \"{o} au BufRead,BufNewFile *.tex inoreabbrev ä \"{a} au ...
3
votes
2answers
272 views

cabbr definitions disturb searching in Vim

I like to define some abbreviations like: cabbr csf cscope find I thought cabbr would just be interpreted in the : command line. However, when I entered the search mode \, I found that \csf would ...
5
votes
1answer
99 views

Can vim automatically correct a spelling mistake if the word doesn't end in a space?

I use vim for writing code and often accidentally type this: funciton() {} instead of function() {} It's irritating and I know vim supports iabbrev for this purpose. But it doesn't work in this ...
3
votes
1answer
152 views

Disabling Automatic Latex Plugin (ATP) mappings

I’m trying to use the Automatic LATEX Plugin for Vim (ATP), and found it has quite neat features. However, I do not like input abbreviations, so I tried to disable them using let g:atp_no_env_maps=1 ...
8
votes
4answers
856 views

Backspace in insert abbreviation

To work, abbreviations need to be separated by whitespace. E.g., if I have an iab fo FOOBAR then typing whatfo will not trigger the abbreviation. There are some obvious sensible reasons for this. ...
4
votes
1answer
161 views

Is it possible to put vim comments in lines that include `iabbrev`

Is it possible to put vim comments in lines that include iabbrev, as in: iabbrev hte the " common typo
3
votes
1answer
637 views

Special characters in iskeywords

I wonder how one can add characters such as (yes, space!), ' (single quote), " (double quote), etc., to iskeyword. This is not a theoretical exercise. The purpose is iabbrev for these. I noticed that ...
0
votes
1answer
49 views

How to fix :cmap breaking :cabbrev [closed]

I have a few :cabbrev mappings that I use frequently, like :qq as a shortcut for :q!. Recently I installed a nifty plugin and these abbreviations no longer triggered with Enter, although Space would ...
10
votes
2answers
299 views

Context sensitive insert mode mapping or abbreviation

I'm planning to implement some utility mappings for my LaTeX plugin to simplify typing of mathematics. For instance, I want to create abbreviations similar to `a : \alpha `b : \beta -> : \to => ...
5
votes
2answers
997 views

Is there a way to set an abbreviation in a modeline so it is always available local to one file buffer?

I have a handful of files (LaTeX documents) that have one specific proper name that is really obnoxious to type out but used frequently. I've eased the pain of this with an abbreviation like so: iab ...