3

I want to use external tr command on a line in Vim. When the source or replace pattern includes Farsi numbers the result is unpredictable.

  • Executing :.!tr 1 ۱ on 1 results:

    Û
    
  • Executing :.!tr ۱ 1 on ۱ results:

    11
    
  • Executing :.!tr 12345 ۱۲۳۴۵ on 12345 results:

    Û±Û²Û
    

The tr command works correctly in the shell with those parameters. How can I fix this (if it is not a bug)?

This is the output of vim --version on my OS X 10.11.4:

 $ vim --version
 VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Apr 22 2016 04:36:23)
 MacOS X (unix) version
 Included patches: 1-1755
 Compiled by Homebrew
 Huge version without GUI.  Features included (+) or not (-):
 +acl             +farsi           +mouse_netterm   +tag_binary
 +arabic          +file_in_path    +mouse_sgr       +tag_old_static
 +autocmd         +find_in_path    -mouse_sysmouse  -tag_any_white
 -balloon_eval    +float           +mouse_urxvt     -tcl
 -browse          +folding         +mouse_xterm     +terminfo
 ++builtin_terms  -footer          +multi_byte      +termresponse
 +byte_offset     +fork()          +multi_lang      +textobjects
 +channel         -gettext         -mzscheme        +timers
 +cindent         -hangul_input    +netbeans_intg   +title
 -clientserver    +iconv           +packages        -toolbar
 +clipboard       +insert_expand   +path_extra      +user_commands
 +cmdline_compl   +job             +perl            +vertsplit
 +cmdline_hist    +jumplist        +persistent_undo +virtualedit
 +cmdline_info    +keymap          +postscript      +visual
 +comments        +langmap         +printer         +visualextra
 +conceal         +libcall         +profile         +viminfo
 +cryptv          +linebreak       +python          +vreplace
 +cscope          +lispindent      -python3         +wildignore
 +cursorbind      +listcmds        +quickfix        +wildmenu
 +cursorshape     +localmap        +reltime         +windows
 +dialog_con      -lua             +rightleft       +writebackup
 +diff            +menu            +ruby            -X11
 +digraphs        +mksession       +scrollbind      -xfontset
 -dnd             +modify_fname    +signs           -xim
 -ebcdic          +mouse           +smartindent     -xsmp
 +emacs_tags      -mouseshape      +startuptime     -xterm_clipboard
 +eval            +mouse_dec       +statusline      -xterm_save
 +ex_extra        -mouse_gpm       -sun_workshop    -xpm
 +extra_search    -mouse_jsbterm   +syntax
    system vimrc file: "$VIM/vimrc"
      user vimrc file: "$HOME/.vimrc"
  2nd user vimrc file: "~/.vim/vimrc"
       user exrc file: "$HOME/.exrc"
   fall-back for $VIM: "/usr/local/share/vim"
 Compilation: /usr/bin/clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X_UNIX  -Os -w -pipe -march=native -mmacosx-version-min=10.11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1
 Linking: /usr/bin/clang   -L. -L/usr/local/lib -L/usr/local/lib -Wl,-headerpad_max_install_names -o vim        -lm  -lncurses -liconv -framework Cocoa   -fstack-protector  -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -lperl -framework Python   -lruby.2.0.0 -lobjc
  • How about setting file encoding to utf8? – SibiCoder Apr 29 '16 at 5:52
  • 1
    What does the following do in your terminal: echo 1 | tr 1 ۱ ? – nobe4 Apr 29 '16 at 6:30
  • @SibiCoder I have set encoding=utf-8 setting in my ~/.vimrc. – Hamid Rohani Apr 29 '16 at 12:14
  • @Nobe4 It works correctly in my terminal. The output is ۱. – Hamid Rohani Apr 29 '16 at 12:15
  • 1
    have a look at vimdoc.sourceforge.net/htmldoc/farsi.html#Farsi, the part Setting the Farsi fonts. Does it help ? – nobe4 Apr 29 '16 at 12:21
1

I had tried version 7.4.1795 before, but the results was the same. Now I upgraded vim:

brew upgrade vim

In the current version 7.4.1817 the problem is solved.

Thank you all for your comments. This is the output of vim --version on my OS X 10.11.4 now:

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled May  7 2016 15:14:50)
MacOS X (unix) version
Included patches: 1-1817
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl             +farsi           +mouse_netterm   +tag_binary
+arabic          +file_in_path    +mouse_sgr       +tag_old_static
+autocmd         +find_in_path    -mouse_sysmouse  -tag_any_white
-balloon_eval    +float           +mouse_urxvt     -tcl
-browse          +folding         +mouse_xterm     +termguicolors
++builtin_terms  -footer          +multi_byte      +terminfo
+byte_offset     +fork()          +multi_lang      +termresponse
+channel         -gettext         -mzscheme        +textobjects
+cindent         -hangul_input    +netbeans_intg   +timers
-clientserver    +iconv           +packages        +title
+clipboard       +insert_expand   +path_extra      -toolbar
+cmdline_compl   +job             +perl            +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    +keymap          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       +python          +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con      -lua             +rightleft       +windows
+diff            +menu            +ruby            +writebackup
+digraphs        +mksession       +scrollbind      -X11
-dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     -xim
+emacs_tags      -mouseshape      +startuptime     -xsmp
+eval            +mouse_dec       +statusline      -xterm_clipboard
+ex_extra        -mouse_gpm       -sun_workshop    -xterm_save
+extra_search    -mouse_jsbterm   +syntax          -xpm
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: /usr/bin/clang -c -I. -Iproto -DHAVE_CONFIG_H   -F/usr/local/Frameworks -DMACOS_X_UNIX  -Os -w -pipe -march=native -mmacosx-version-min=10.11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: /usr/bin/clang   -L. -L/usr/local/lib -L/usr/local/lib -F/usr/local/Frameworks -Wl,-headerpad_max_install_names -o vim        -lm  -lncurses -liconv -framework Cocoa   -fstack-protector  -L/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE -lperl -framework Python   -lruby.2.0.0 -lobjc    

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.