4
votes

I have the following line of text:

Foo bar 15 test.

My cursor is on the F at the start of the line, and I am in normal mode. I want to decrement 15 by 10, so my line reads like so:

Foo bar 5 test.

Apparantly, I should therefore, without moving my cursor, be able to type 10 and then hold down Control and type x. This is however only decrementing my number by 1, as opposed to 10.

Is there maybe an add on that vim needs to be able to do this, or do I need to change a setting in vim for this to work. I am using vim without the GUI running on Ubuntu 12.04 Server via Putty.

My version of vim is as follows:

:version VIM - Vi IMproved 7.3 (2010 Aug 15, compiled May 4 2012 04:09:27) Included patches: 1-429 Modified by [email protected] Compiled by buildd@ Huge version without GUI. Features included (+) or not (-): +arabic +autocmd -balloon_eval -browse ++builtin_terms +byte_offset +cindent -clientserver -clipboard +cmdline_compl +cmdline_hist +cmdline_info +comments +conceal +cryptv +cscope +cursorbind +cursorshape +dialog_con +diff +digraphs -dnd -ebcdic +emacs_tags +eval +ex_extra +extra_search +farsi +file_in_path +find_in_path +float +folding -footer +fork() +gettext -hangul_input +iconv +insert_expand +jumplist +keymap +langmap +libcall +linebreak +lispindent +listcmds +localmap -lua +menu +mksession +modify_fname +mouse -mouseshape +mouse_dec +mouse_gpm -mouse_jsbterm +mouse_netterm -mouse_sysmouse +mouse_xterm +mouse_urxvt +multi_byte +multi_lang -mzscheme +netbeans_intg +path_extra -perl +persistent_undo +postscript +printer +profile +python -python3 +quickfix +reltime +rightleft -ruby +scrollbind +signs +smartindent -sniff +startuptime +statusline -sun_workshop +syntax +tag_binary +tag_old_static -tag_any_white -tcl +terminfo +termresponse +textobjects +title -toolbar +user_commands +vertsplit +virtualedit +visual +visualextra +viminfo +vreplace +wildignore +wildmenu +windows +writebackup -X11 -xfontset -xim -xsmp -xterm_clipboard -xterm_save system vimrc file: "$VIM/vimrc" user vimrc file: "$HOME/.vimrc" user exrc file: "$HOME/.exrc" fall-back for $VIM: "/usr/share/vim" Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H
-g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Wformat-security -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 Linking: gcc -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed -o vim -lm -ltinfo -lnsl -lselinux -lacl -lattr -lgpm -ldl -L/usr/lib/python2.7/config -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O 1 -Wl,-Bsymbolic-functions

Thanks

1
Are you sure you're holding down Control? Or are you just deleting the character 5 with x? What happens when you do 10<C-A> instead?glts
@glts I am holding down control yes. when I use A as opposed to x I increment by one. It works properly when my cursor is actually on the number, but my understanding is that this should work even if my cursor is at the start of the line, is this correct?JMK
You are probably using vi, or Vim in compatible mode. It doesn't support using a count with <C-A>/<C-X>. Upgrade to a proper Vim.glts
I've added the response from running the version command to my question, I don't see anything about compatibility mode and it is definitely full vim.JMK
What does :set compatible? say? If it's compatible, do :set nocp and try 10<C-X> again.glts

1 Answers

7
votes

You're probably running Vim in compatible mode.

The command

:set nocompatible

puts Vim in nocompatible mode and magically enables various useful features not present in vi, including using a count with CtrlA and CtrlX.

If you always want to start Vim in nocompatible mode (which is strongly recommended), create a basic vimrc file in your home directory with the following contents.

set nocompatible
filetype plugin indent on

If you're new to Vim and don't know what a vimrc file is, read the introduction in the help at :h vimrc-intro.